3

I know how to use INNER JOIN via the LINQ query expression syntax:

var query =
    from table1 in context.Table1
    join table2 in context.Table2 on table1.Table2FkField equals table2.ID
    select new { table1.SomeField, table2.SomeField };

But in some situations, it is more readable to use method syntax.

So the question is how to rewrite the example above using LINQ method syntax?

I've founded many answers on SO related to the LINQ INNER JOIN but all of them use query expression syntax.

Servy
  • 202,030
  • 26
  • 332
  • 449
Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
  • 3
    _"in some situations it is more readable to use lambda notation"_ definitely not with joins. – Tim Schmelter Aug 12 '14 at 20:38
  • 1
    If you have a complex LINQ-to-SQL query that combines labda and query expressions, and in some point of that you want to do an INNER JOIN, it's very unlikely that you want wrap the whole query in from-join-select expression. This is where lambda INNER JOIN notation might come into action to increase readability. So never say never. – Alexander Abakumov Aug 12 '14 at 20:50
  • 1
    The term you're looking for is method syntax. Using LINQ with either query syntax or method syntax use lambdas. – Servy Aug 12 '14 at 20:57
  • @GrantWinney, thank you for the link to another SO answer. This explains what I'm asking for. – Alexander Abakumov Aug 12 '14 at 21:00

0 Answers0