Skip to content

Deferred operators

Context: Deferred operators (e.g., Where, Select, OrderBy) do not execute until the query is enumerated. They return an IEnumerable<T>.

var deferred = numbers.Where(n => n > 2); // no execution
// Execution happens here
foreach (var item in deferred) { }
  • Where, Select, SelectMany
  • Take, Skip
  • OrderBy, OrderByDescending, ThenBy
  • GroupBy, Join, GroupJoin
  • Concat, Distinct, Union, Intersect, Except

Complex query composition: Deferred execution allows you to build queries conditionally without performance penalty until the final enumeration.

Example: In EF Core, all IQueryable operators are deferred until ToList() or foreach.