I would like to be able to iterate through every row in an entity table without holding every row in memory. This is a read only operation and every row can be discarded aft
I haven't tested it, but try foreach (Quote L in context.Quotes.AsNoTracking()) {...}
. .AsNoTracking()
should not put entities in cache so I assume they will be consumed by GC when they out of the scope.
Another option is to use context.Entry(quote).State = EntityState.Detached;
in the foreach loop. Should have the similar effect as the option 1.
Third option (should definitely work, but require more coding) would be to implement batch processing (select top N entities, process, select next top N). In this case make sure that you dispose and create new context every iteration (so GC can eat it:)) and use proper OrderBy() in the query.