Linq to Entities (3.5) Children not loading
Posted on 2012-08-22
I'm trying to convert from linq to sql to linq to entities as my team doesn't like the code being tightly coupled (no complaints).
I'm running into issues where I can't load the associated child record.
I manually created an association from the Order table to the Label_Proof table. It's a one to one.
dm is my instance of the entity
I'm trying to do:
dim lp as Label_Proof = dm.Orders.Include("Label_Proof").Where(Function(o As Order) o.Order_Number = RunCode).FirstOrDefault.Label_Proof
but lp is always coming back nothing.
However if I take out the where clause and just do:
it comes back fine.
I have verified that the label_proof actually exists for the runcode in question. I can assign the order to a variable and do a manual lookup on label proofs, but that seems cumbersome.
Note this is EntityFrameworks 1 using .Net 3.5 in VS2008.
Any and all help greatly appreciated.