Their piecemeal on-demand evaluation characteristic makes iterators an ideal construct to express queries. Because the underlying data source can potentially change after you have declared a query expression, delaying the execution is a much desirable feature:
The query expression used here is compiled into a call to the
Where query operator we’ve seen before. Because it’s realized using iterators, it’s only when we enumerate over the query object that execution starts to take place. Because of this, a query expression is nothing more than a declaration of the intent of the query.
That said, some query operators trigger immediate ...