New Posts New Posts RSS Feed: Covariance in IEntityQuery<T>?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Covariance in IEntityQuery<T>?

 Post Reply Post Reply
Author
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Topic: Covariance in IEntityQuery<T>?
    Posted: 13-Jul-2010 at 6:47pm
Great idea.  We looked at this last year and really wanted to do it, but Silverlight does not support covariance/contravariance yet and we did not want to break the consistency of our API.
Back to Top
stephenmcd1 View Drop Down
DevForce MVP
DevForce MVP


Joined: 27-Oct-2009
Location: Los Angeles, CA
Posts: 166
Post Options Post Options   Quote stephenmcd1 Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2010 at 11:39am
With the move to .NET4 and it's covariance/contravariance support, I'm wondering if it would be possible to mark IEntityQuery<T> covariant?  It looks like the standard IQueryable<T> and IOrderedQueryable<T> already support covariance.

One reason I'd really like to see this is for situations like the following:

public IEntityQuery<MyBaseEntityType> GetASemiDynamicEntityQuery(bool someCriteria)
{
    if(someCriteria)
        return myEntityManager.Table1;
    else
        return myEntityManager.Table2;
}

As it stands now, the return type would have to be the non-generic IEntityQuery but then I couldn't perform further type-safe filtering or ordering, etc. on the query.

Thanks!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down