is there a way to get a LINQ query result on a EF DBContext as a 'Typed Data Reader', in sucha a way that when i am reading de IQueryable result (ex with a .ToList()) I don't put all the result in memory?
I am expecting something like this (or equivalent):
var personQueryResult=dbContext.People.Where(…).Select(…).AsDataReader();
foreach(person in personQueryResult){
//Here I expect that person is typed of the People Dbset<T> type, ex. a Person type and i can do:
person.Name="...";
person.Surname="...";
//etc.
}
DataReader
- no. But pulling the whole result set in memory viaToList
is not mandatory - treating the query asIEnumerable<T>
(eventually combined withAsNoTracking
) andforeach
-in it is pretty much an equivalent of "entity"DataReader
because you read one item at the time.IEnumerable<T>
is definitely the right approch! Thank you!