Writing LINQ queries
Although we wrote a few LINQ queries in Chapter 11, Working with Databases Using Entity Framework Core, they weren't the focus, and so I didn't properly explain how LINQ works, but let's now take time to properly understand them.
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, LINQ to Entities, LINQ to XML, LINQ to OData, and LINQ to Amazon. These are what convert standard LINQ operations into specific commands for different types of data.
- Lambda expressions (optional): These can be used instead of named methods to simplify LINQ extension method calls.
- LINQ query comprehension syntax (optional): These include
from
,in
,where
,orderby
,descending
, andselect
. These are C# keywords that are aliases for some of the...