Need help converting a nested SQL statement to LINQ?

Well, the simplest translation would be: var query = from a in aTable where (from be in bTable where (from c in cTable where (from d in dTable where dField == "a guid" select d. CTableId) . Contains(c.

CTableId) select c. BTableId) . Contains(b.

BTableId) select b. ATableId) . Contains(a.

ATableId) select a However, it's likely that a join would be significantly simpler: var query = from a in aTable join be in bTable on a. ATableId equals b. ATableId join c in cTable on b.

BTableId equals c. BTableId join d in dTable on c. CTableId equals d.

CTableId where d. DField == "a guid" select a I haven't checked, but I think they'll do the same thing.

Well, the simplest translation would be: var query = from a in aTable where (from be in bTable where (from c in cTable where (from d in dTable where dField == "a guid" select d. CTableId) . Contains(c.

CTableId) select c. BTableId) . Contains(b.

BTableId) select b. ATableId) . Contains(a.

ATableId) select a; However, it's likely that a join would be significantly simpler: var query = from a in aTable join be in bTable on a. ATableId equals b. ATableId join c in cTable on b.

BTableId equals c. BTableId join d in dTable on c. CTableId equals d.

CTableId where d. DField == "a guid" select a; I haven't checked, but I think they'll do the same thing...

That's what I needed. The only addition was to define the type in the . Contains statements.Ie: .

Contains((Guid) a. ATableId) – levi rosol Apr 30 '09 at 21:31 and yes, although the SQL is different for both of these options, the Execution Plan is identical. The second option using Joins is a much more readable solution.

– levi rosol Apr 30 '09 at 21:53.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions