LINQ: Dot Notation vs Query Expression

The “dot” notation is usually called Lambda syntax. The first notation goes by a number of names but I usually call it the query syntax.

I work on a team of 10 developers and we argue at length about which we should use as a standard. In general, the more seasoned (with LINQ) developers migrate towards the Lambda syntax but there are significant exceptions.

Lambda is more concise but performing multiple table joins is a nightmare. Joins are just much cleaner with the query syntax. The flip side is that there are a number of LINQ operations that only exist within the Lambda syntax: Single(), First(), Count() etc.

So, use what you feel most comfortable with and realize that as you gain experience, your preference will likely change. There is great value in being able to read both and there will certainly be situations where you have to use a little bit of both. Other situations will lend themselve to one style over the other. In the end, it all gets translated into the same executable code.

Leave a Comment