Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#IEnumerable vs IQueryableSingle-choice MCQ

Why does casting an `IQueryable<T>` to `IEnumerable<T>` before further LINQ calls change the behavior of those subsequent calls?

IQueryable<Person> q = db.People; var a = q.Where(p => p.Age > 18).Count(); // path A var b = ((IEnumerable<Person>)q).Where(p => p.Age > 18).Count(); // path B