I have the following example:
using (MyContext context = new MyContext())
{
var query = from entityA in context.EntityA.Include("TestProperty")
join entityB in context.EntityB on entityA.Id equals entityB.EntityAId
join entityC in context.EntityC on entityB.Id equals entityC.EntityBId
where entityC.Id == id
select entityA;
List<EntityA> toReturn = query.ToList();
return toReturn;
}
My joins are all working as expected, however, my 'TestProperty' navigation property is not loaded properly. I look, during runtime, and it is null.
When I do the following:
context.LoadProperty(toReturn, "TestProperty");
It loads the 'TestProperty' property correctly. Is there something I am doing incorrectly in my LINQ-to-SQL statement?
UPDATE: I changed the first line to be:
from entityA in context.EntityA.Include("TestProperty").ToList()
And left the rest of the lines below that the same and it loaded my property correctly. Is this the proper solution to the problem?