This one had me banging my head for the last couple of hours…  I have Entity A, B, and C in my Entity Diagram with A linking to B and B linking to C.  I want to find all of the C items that are associated with a specific instance of A.  Running through a range of ways to solve the issue got me no where, other than frustrated.  Fortunately, I found the answer on StackOverflow.com with this article.  Long and short of it is that one has to do a .Include statement in the LINQ query on the table to include everything needed.  So, the code would look like this:

var foo = from tempA in A.Include(“Bs.Cs”)

where tempA.Id = 1234

select tempA;

At that point, all of the B and C child objects are loaded.

I’ll just shake my head and refrain from commenting….

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s