I didn't see this as an existing issue when searching just now, but morelinq
seems like a good place for a Memoize extension method.
The goal is to allow callers to iterate over a sequence multiple times, but
caching the results so the inner/original sequence is still only iterated once.
The most common use case I've seen for this is when interacting with sql
queries. If you use ToList/ToArray or the like (as many people do), you end up
forcing your code to wait until all the results have been pulled into memory
from the server. Memoize improves this situation by allowing you to start
pulling from the queryable immediately, but without having to incur the penalty
if you end up needing to iterate over it multiple times (as the data gets
cached as it's been pulled from the source).
An example gist can be found here to get across the idea:
https://gist.github.com/thomaslevesque/3345186
Original issue reported on code.google.com by james.ma...@gmail.com on 1 May 2015 at 2:40
Original issue reported on code.google.com by
james.ma...@gmail.com
on 1 May 2015 at 2:40