I know that IQueryable
has the advantage of running filters on server rather loading all records in memory like IEnumerable
, but how does exactly this look like in code, for example, if I have this code:
var data = context.Books.Where(x => x.Id > 930);
if I have 1000 records then it will only load 70 records, and to iterate over them, I convert data
to List:
var list = data.ToList(); //has only 70 records
but what are the cases that IEnumerable
load all records if it has to pass through IQueryable
first
i.e. to get the IEnumerable
version of the example above:
var eData = context.Books.Where(x => x.Id > 930).ToList();
Aren't they the same? the last code is no more than combining the above two lines of code?