Writing LINQ Expressions
Learn about LINQ, its components, the concept of deferred execution, and LINQ extension methods.
Although we wrote a few LINQ expressions, they weren’t the focus, so we didn’t understand properly how LINQ works. Let’s now take time to properly understand LINQ expressions.
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 execute LINQ expressions in a way specific to different data types.
Lambda expressions (optional): These can be used instead of named methods to simplify LINQ queries, for example, for the conditional logic of the
Where
method for ...