How to transform my query into a Linq query?

0

I need to mount this query on Entity

select
ped.Id,
 prot.Prot_numero as Protocolo,
 ori.Descricao as Sistema,
 cla.Id as Equipe,
 cla.Descricao as Finalidade,
 forn.Nome as Fornecedor
from Pedidos ped
join Protocolo prot on ped.ProtocoloId = prot.Id
join Origem ori on ori.Id = prot.OrigemId
join Classificacao cla on cla.Id = prot.ClassificacaoId
left join Contrato cont on ped.ContratoId = cont.Id
left join Fornecedor forn on cont.CodigoSAP = forn.CodigoSAP
where StatusPedidoId = 9

Only when I put groupjoin it gives me error.

  

The type arguments for method can not be inferred from the usage

Linq:

var infoPedidos = db.Pedidos.Where(p => p.StatusPedidoId == 9)
 .Join(db.Protocolos, ped => ped.ProtocoloId, prot => prot.Id, (ped, prot) => new {
  ped,
  prot
 })
 .Join(db.Origens, prot => prot.prot.Id, ori => ori.Id, (prot, ori) => new {
  prot,
  ori
 })
 .Join(db.Classificacao, prot => prot.prot.prot.ClassificacaoId, cla => cla.Id, (prot, cla) => new {
  prot,
  cla
 })
 .GroupJoin(db.Contratos, cont => cont.prot.prot.ped.ContratoId, ped => ped.Id, (cont, ped) => new {
  cont,
  ped
 })

.Select(x => new {
 x.prot.prot.prot.prot.Id
});

How to do it?

    
asked by anonymous 14.06.2018 / 14:37

0 answers