Method syntax

The LINQ queries you’ve seen and written so far use QUERY SYNTAX, which expresses your query as a series of clauses (from, where, etc.) in a statement. LINQ also provides another way of expressing queries, called METHOD SYNTAX, which, as you might expect, expresses the query using method calls rather than statements.

Instead of expressing a query as a statement:

Image

You can express it as a method call:

Image

Query syntax is the recommended format (does anybody actually enjoy writing lambdas?), but some LINQ methods, like Count() and Average() ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.