deferred execution
Building a query now but running it only when something asks for its results.
In more detail
Where returns an object that remembers the source and the predicate and filters nothing until a foreach, ToList or First pulls items. This lets you compose a query in one method and decide where it runs in another.
Related terms
- LINQ — Language Integrated Query: a set of C# operators such as Where, Select and OrderBy for filtering, shaping and combining sequences of data.
- terminal operator — A LINQ call such as ToList, First, Count or Sum that actually runs a deferred query and produces a result.
- iterator — An object that produces the items of a sequence one at a time, on request, instead of all at once.
- IQueryable<T> — The .NET interface for a query that a provider such as EF Core translates and runs elsewhere, typically as SQL in a database.
Taught in
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Querying, Change Tracking, and Saving Data — Modern .NET Core, C# & Enterprise Microservices