I got little confused with following scenario,
- I have model 'Student'
- I have SchoolContext class - public property DbSet Students{get;set;}
Service, with following line of code
using(var context = new SchoolContext()) { var query = context.Students.Where(s => s.Gender =="M"); var results = query.ToList(); }
While debugging, I mouse hover on context.Students & expand property Results View and realized all students are already loaded irrespective of filter and after filter-where is getting applied.
I am not sure, however, I read somewhere that until pointer hits .ToList() everything remains under IQueryable. So here in this case var query supposed to be IQueryable without loading any data and just query with where condition and next line then will hit database with generated query and return only needed data.
Am I missing anything or mixing it with any other concept of EF?
Studentswhen you hovered over the property, in production this would not happen. - Igor