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.