IEnumerable vs IQueryable
Overview
Section titled โOverviewโIEnumerable<T>
runs in-memory; IQueryable<T>
builds expression trees for remote providers (EF Core, OData) to translate.
Introduced In
Section titled โIntroduced Inโ.NET 3.5 LINQ era (2007)
Key Differences
Section titled โKey Differencesโ- IEnumerable: LINQ-to-Objects, methods take Func delegates.
- IQueryable: LINQ providers, methods take Expression trees; operations may translate to SQL.
Gotchas & Best Practices
Section titled โGotchas & Best Practicesโ- Donโt call ToList() too early; keep filtering server-side with IQueryable.
- Be cautious with client-eval; ensure provider supports operations.