IEnumerable<T> and IQueryable<T> are the two most used terms of any LINQ discussion. What I am trying to here is that I am trying to simplify the two interfaces depending on their behavior. In LINQ world we generally have few providers available within .NET Framework, like LINQ to Object, LINQ to SQL, LINQ to XML.
It is a statement that every LINQ statement returns IEnumerable<T>. IEnumerable works in steps. Meaning, when you write,
var q = from a in b
where a > 5
It creates a list out “b” depending on “where” then it creates another list for “select”. This is the behavior of LINQ to Object and LINQ to XML.
When you use LINQ to SQL it uses IQueryable<T>. This interface inherits from IEnumerable<T> but typically any LINQ to SQL generates T-SQL at the backend to be able to get the data for us. This evaluate and generates the query at one shot and gives us the whole data.
IEnumerable<T>: Iterated in-memory
1. Out-of-memory e.g. Database or WebServices
2. Extends IEnumerable interface for better query support.
IEnumerable<T> : Iterated in-memory
IQueryable<T> : Out of memory (e.g. Database or WebServices) and Extends IEnumerable interface
Nice explanation. Easy to understand.