Writing LINQ expressions
Although we wrote a few LINQ expressions in Chapter 10, Working with Data Using Entity Framework Core, they weren't the focus, and so I didn't properly explain how LINQ works, so let's now take time to properly understand them.
What makes LINQ?
LINQ has several parts; some are required, and some are optional:
- Extension methods (required): These include examples such as
Where
,OrderBy
, andSelect
. These are what provide the functionality of LINQ. - LINQ providers (required): These include LINQ to Objects for processing in-memory objects, LINQ to Entities for processing data stored in external databases and modeled with EF Core, and LINQ to XML for processing data stored as XML. These providers are what execute LINQ expressions in a way specific to different types of data.
- Lambda expressions (optional): These can be used instead of named methods to simplify LINQ queries, for example, for the conditional logic of the...