I created a join in LINQ
to create a List
:
(from p in listaProcedimento
join pd in oListaprocedimentodetalhe on p.codigo equals pd.codigoProcedimento into pd1
from pd2 in pd1.DefaultIfEmpty()
select new ProcedimentoDetalhe()
{
codigoDetalhe = pd2.codigoDetalhe == null ? "000" : "012",
codigoProcedimento = p.codigo,
descricao = p.descricao,
idadeMax = p.idadeMax,
idadeMin = p.idadeMin
}).OrderBy(p => p.descricao)
.ToList();
I get the error saying that pd2 was null
, being that I already tried to correct this in line: pd2.codigoDetalhe == null ? "000" : "012"
.
Why is not it working?