IHAC that prefers entity framework over code where possible, existing DB (so changing the schema is out of the question). I'm trying to get a list of unique E elements given an A id. I'm new to MS Entities, and its not how I would handle it (I think for some of the complex things that this group is doing with them they are slower than snot on ice) but Its what I've been handed.
Here's a quickie diagram:
THIS IS NOT MY DB DESIGN! Don't shoot the questioner :)
Here's the SQL I'd write:
SELECT E.e_Id, E.e_Name
FROM
A,
B,
C,
D,
E
WHERE
A.a_Id = 'someid'
AND A.a_Id = B.a_Id
AND B.b_Id = C.b_Id
AND C.d_Id = D.d_Id
AND D.e_Id = E.e_Id
GROUP BY E.e_Id, E.e_Name
Stepwise, I can get to the table D Entities, but then I can't figure out how to get to the E Entities:
var bLocal = context.AEntities
.Where( a => a.a_Id == 'someid' )
.Select( b => b.B );
var dLocal = bLocal
.SelectMany( b => b.D );
var eLocal = dLocal. ????
- OR? -
var eLocal = context.EEntities ???