我有一个有2个连接组的组连接,其中一个组连接可以为null,在我的查询中C是我用左连接加入的组此查询给我和null异常
from A in contexto.A.Where(i => i.EmpresaId == id)
join B in contexto.B
on A.Id equals B.AId
join D in contexto.D
on B.BId equals D.Id
join C in contexto.C
on A.Id equals C.AId
into c
from C in c.DefaultIfEmpty()
group new { A, C, D} by A into grupo
select new ADTO{
Clave = grupo.Key.Clave,
Nombre = grupo.Key.Nombre,
Lista1 = grupo.Select(t =>
t.D.Nombre
).ToList(),
Valores1 = grupo.Select(t => new ValorDTO
{
a= t.C.A,
b= t.C.B,
c= t.C.c
}
).DefaultIfEmpty(new ValorBMDTO()).ToList()
}).ToList();