This is the eleventh part of the "LINQ" series of articles that I have started from here. In the previous article you learned how to perform calculations in a LINQ query. Now, in this article you will look at some differences between LINQ Query Syntax and Method Syntax used in LINQ.
All the queries we have learned in this series so far are known as LINQ Query Syntax that was introduced with the C# 3.0 release. Actually, at compile time queries are translated into something that the CLR understands. So, it makes a method call at runtime to produce standard SQL queries that uses real SQL keys like WHERE, SELECT, GROUPBY, JOIN, MAX, AVERAGE, ORDERBY and so on. So, we have a direct way to avoid such method calls to produce standard SQL and that is known as Method Syntaxes.
If you ask me, I recommend Query Syntax because it is usually simpler and more readable; however there is no semantic difference between Method Syntax and Query Syntax. In addition, some queries, such as those that retrieve the number of elements that match a specified condition, or that retrieve the element that has the maximum value in a source sequence, can only be expressed as method calls. The reference documentation for the standard query operators in the System.Linq namespace generally uses Method Syntax. Therefore, even when getting started writing LINQ queries, it is useful to be familiar with the use of Method Syntax in queries and in query expressions themselves. [Source: MSDN]

Join the conversation! Your thoughts help the community grow.