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.