Although we wrote a few LINQ queries in Chapter 11, Working with Databases Using Entity Framework Core, I didn't properly explain how LINQ works.
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 LINQ extension methods, and their use can simplify the queries you write, especially if you already have experience with other query languages...