Immediate operators
Context: Immediate operators execute the query immediately and return a concrete result (e.g., list, single value, dictionary).
var numbers = new[] { 1, 2, 3 };var list = numbers.Where(n => n > 1).ToList(); // executes nowvar first = numbers.First(); // executes nowCommon immediate operators
Section titled “Common immediate operators”ToList(),ToArray(),ToDictionary(),ToHashSet()First(),FirstOrDefault(),Last(),Single()Count(),Sum(),Average(),Min(),Max()Any(),All(),Contains()
Real-world usage example
Section titled “Real-world usage example”Materializing results for caching: Use ToList() to execute a query once and store the result, avoiding repeated database calls.
Example: In ASP.NET Core, you might materialize a query to cache the data.