Join selected anonymous object with another table

34 views Asked by At

I have a join

var result = 
    from a in dbContext.As
    join b in dbContext.Bs on a.Id equals b.A.Id
    select new { A = a, Ds = b.AList.Select(listItem => listItem.ObjectOfTypeD) }
    join c in dbContext.Cs on ANONYMOUS_OBJECT.Ds.Id equals c.ObjectOfTypeD.Id

how can I join the contents of my select clause with dbContext.Cs?

1

There are 1 answers

0
Svyatoslav Danyliv On

You can continue Query Syntax LINQ expression by into operator after select:

var result = 
    from a in dbContext.As
    join b in dbContext.Bs on a.Id equals b.A.Id
    select new { A = a, Ds = b.AList.Select(listItem => listItem.ObjectOfTypeD) }
    into s
    join c in dbContext.Cs on s.Ds.Id equals c.ObjectOfTypeD.Id
    select new { s, c };