Let’s look at Definition for IEnumerable first
public interface IEnumerable
{
IEnumerator GetEnumerator();
}
And
when you drill further for IEnumerator definition, it looks like this
public interface IEnumerator
{
bool MoveNext();
object Current { get; }
void Reset();
}
And
Now let’s looks at definition for IQueryable
public interface IQueryable : IEnumerable
{
// Summary:
// Gets the type of the element(s) that are returned when the expression tree
// associated with this instance of System.Linq.IQueryable is executed.
//
// Returns:
// A System.Type that represents the type of the element(s) that are returned
// when the expression tree associated with this object is executed.
Type ElementType { get; }
//
// Summary:
// Gets the expression tree that is associated with the instance of System.Linq.IQueryable.
//
// Returns:
// The System.Linq.Expressions.Expression that is associated with this instance
// of System.Linq.IQueryable.
Expression Expression { get; }
//
// Summary:
// Gets the query provider that is associated with this data source.
//
// Returns:
// The System.Linq.IQueryProvider that is associated with this data source.
IQueryProvider Provider { get; }
}
So IQuryable interface is derived from IEnumerable interface and
has 3 extra properties which are ElementType, Expression and Provider, which indicates
that it should be used with expression trees. An expression tree represents
code in a tree like data structure , where each node is an expression , for
example a method call or binary operations such as x < y.
You can compile and run code represented by expression
trees. This enables dynamic modification of executable code, the execution of LINQ
queries in various databases, and the creation of dynamic queries.
You can have the C# or Visual Basic compiler create an
expression tree for you based on an anonymous lambda expression, or you can
create expression trees manually by using the
System.Linq.Expressions
namespace.