Here's a bunch of things I tried... hopefully you can extrapolate from it what I'm trying to do and what I'm doing wrong. Okay so I'm having problems with loading related entities when using this DoQuery:
public ObjectQuery<E> DoQuery(ISpecification<E> where)
{
return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Name + "]").Where(where.EvalPredicate);
}
If I just use this, I end up getting an object back that contains all proper parameters except the ones that are related entities... ie. if one is a UserID that's referenced to the User table, I do not get back the User object as well.
I read up that you can do a .Include("User") to do an Eager Load of the entity... but it doesn't work when I try this:
public ObjectQuery<E> DoQuery(ISpecification<E> where)
{
return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Name + "]").Include("User").Where(where.EvalPredicate);
}
I also checked to make sure the Entity Set Name and model name are "User", which they are. The only other thing I could think of is to put multiple things in the ("[" + typeof(E).Name + "]")
but I'm not sure how to include multiple entities in there... Here's what I tried since I saw someone said you could load multiple by putting a . inbetween.
public ObjectQuery<E> DoQuery(ISpecification<E> where)
{
return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Name + "].[User]").Where(where.EvalPredicate);
}
But that didn't work...
If I'm not on the right track please let me know. Does anyone know how to load the related entities when using ObjectContext.CreateQuery? Any suggestions or insight helps.
Thanks,
Matt