Showing posts with label linq. Show all posts
Showing posts with label linq. Show all posts

Thursday, May 8, 2008

IQueryable and IQueryProvider

This post by Bart Linq to Active Directory gives good insight of how linq to anything works but it was based on .Net 3.5 Beta1 release and used IQueryable interface because IQueryProvider was introduced while Beta2.

Actually, the IQueryable interface was factored into two interfaces while Beta2 release:

1. IQueryable
2. IQueryProvider

If you use Visual Studio to ‘Go to definition’ you get something that looks like this:

public interface IQueryable : IEnumerable {

Type ElementType { get; }

Expression Expression { get; }

IQueryProvider Provider { get; }

}

public interface IQueryProvider {

IQueryable CreateQuery(Expression expression);

IQueryable CreateQuery(Expression expression);

object Execute(Expression expression);

TResult Execute(Expression expression);

}

Through Linq to Amazon example you can see how it would change the Linq to Active Directory implementation by Bart.

Good resource: Linq to Everything: A List of LINQ Providers