If IQueryable <T> inherits IEnumerable <T>, why is IQueryable <T> LINQ to SQL?
You are mistaken in inheritance and implementation of the interface.
IQueryable<T>inherits IEnumerable<T>, but this is radically different from class-to-class inheritance, where a derived class inherits an implementation of the base class. Interfaces are just contracts, there is no real code behind them:
public interface IFoo
{
void Foo(); //its simply a contract, no implementation at all.
}
public interface IBar: IFoo
{
void Bar();
}
public class Foo: IFoo
{
void Foo() { //Foo sepecific implementation goes here }
}
public class Bar : IBar
{
void Foo() { //Bar specific implementation goes here }
void Bar() { //implementation goes here }
}
The fact that it Barimplements IFoothrough IBardoes not in any way mean that there is any connection between Fooand Bar.
How can IQueryable filter rows in a database while IEnumerable filters objects in memory?
They do not, this is an inaccurate statement.
The actual implementation code is inside extension methods that are selective for IEnumerable or IQueryable.
In EF there is
Where<T>(this IQueryable<T>, Expression<Predicate<T>> )
and in System.Linq there is
Where<T>(this IEnumerable<T>, Predicate<T>)
resoluton IQueryable Linq, Expression<>.