+ 1

What does AsEnumerable() do for Dbset classes

So I'm trying to retrieve data from a database through a database context, but when I'm trying to filter with only Where(), it throws an error Here's the code: using (var context = new DbContext()) { var adults = context.People //.AsEnumerable() .Where(x => x.Age >= 18); }

31st Aug 2021, 6:40 PM
Tim
Tim - avatar
2 ответов
+ 1
AsEnumerable down casts to IEnumerable and causes the following query operators (.Where...) to bind to an enumerable operator instead. This makes subsequent query execute locally.
4th Sep 2021, 6:09 PM
DavX
DavX - avatar
0
DavX, thank you
4th Sep 2021, 7:47 PM
Tim
Tim - avatar