What should you use for joining in LINQ, Query syntax or method syntax?

Viewed 1232

I would like to know in terms of performance is there any difference between using a query syntax or method syntax (Lambda expressions) for joining two entities?

I already know that in general there are no difference in terms of result, between query syntax and method syntax. However, for joining which of these are better to use performance wise? Here is the sample code:

var queryResult = (from p in People
                       join i in Incomes
      on p.PersonId equals i.PersonId
                       select new { p.PersonId, p.Name, p.Age, i.Amount }
                      ).ToList();

        var lambdaResult = People.Join(Incomes,
                      p => p.PersonId,
                      i => i.PersonId,
                     (p, i) => new { p.PersonId, p.Name, p.Age, i.Amount }).ToList();

I have already went through these websites but nothing has been mentioned for join https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/query-syntax-and-method-syntax-in-linq

LINQ - Query syntax vs method chains & lambda

1 Answers
Related