I am working with Entity Framework code-first, and I have a class Course which has a navigation property Students:
public virtual C
If you were to use proper variable typing then you would see what is happening. The entire set is lazy loaded loaded into memory by the navigation property.
//user is an instance of the class User referenced by DbSet
//when you lazy load a navigation property in that set, it loads the data
ICollection allStudents = user.Students;
//At this point, all of the data was lazy loaded
//But the Where creates an IEnumerable of the in memory set
IEnumerable activeStudents = allStudents.Where(n => n.Active);
//At this point, the IEnumerable is iterated, and a List is returned
List listOfActiveStudents = activeStudents.ToList();