LINQ Interview Question #80
What is streaming execution in LINQ?
Deferred Execution, Immediate Execution & Query Behavior Mid-Level Intermediate
Quick Interview Answer
A streaming LINQ operator can process and yield elements without first consuming the entire source. Where and Select are common examples.
Detailed Explanation
A streaming LINQ operator can process and yield elements without first consuming the entire source. Where and Select are common examples.
Streaming can reduce memory usage and allow early termination. Operators such as OrderBy and some grouping operations are non-streaming because they need more or all of the source before returning results.
Code Example
var firstMatch = numbers
.Where(n => n > 100)
.Select(n => n * 2)
.FirstOrDefault();