Deferred vs immediate execution
Context: LINQ queries are not executed when defined, but when iterated (deferred). Some operators force immediate execution.
int[] numbers = { 1, 2, 3 };var query = numbers.Where(n => n > 1); // not executed yetnumbers[0] = 10; // change sourceforeach (var n in query) // executed now, uses updated data{ Console.WriteLine(n); // 10,2,3}Real-world usage example
Section titled “Real-world usage example”Live data views: Deferred execution allows you to define a query that always reflects the latest data (e.g., filtering a live collection).
Example: In Blazor, you can bind a UI list to a deferred query that updates when the source changes.