Following on from my previous question: Simple inner join in linq
How would I write some linq to do exactly the same as the below..
SELECT A.name, B.name
FROM A
INNER JOIN B ON A.id = B.AID
INNER JOIN C ON B.id = C.BID
GROUP BY A.Name, B.Name
ORDER BY A.Name
I've tried this but it generates nested selects and thus produces a different number of rows.
var r = from a in db.A
join b in db.B on a.Id equals b.AId
join c in db.C on b.Id equals c.BId
group c by c.B into g1
group b by g1.Key.A into g2
select g2.Key;
I need a group of A
's that contains a list of B
's which contains a list of C
's