Search code examples
entity-frameworkobjectquery

ObjectQuery<T> without Entity Framework


How to use ObjectContext and ObjectQuery<T> with my own classes and objects?

I.e. I don't want to use them with Entity Framework.

How can I do this?


Solution

  • ObjectContext and ObjectQuery are the Entity Framework. You could implement your own Custom Linq Provider. A very good example can be found at "THE WAYWARD WEBLOG" http://blogs.msdn.com/mattwar/pages/linq-links.aspx. This Blog helped me implementing my own custom Provider.

    public interface IQueryable : IEnumerable {       
        Type ElementType { get; }
        Expression Expression { get; }
        IQueryProvider Provider { get; }
    }
    
    public interface IQueryProvider {
        IQueryable CreateQuery(Expression expression);
        IQueryable<TElement> CreateQuery<TElement>(Expression expression);
        object Execute(Expression expression);
        TResult Execute<TResult>(Expression expression);
    }