I need to make a count
, for the following situation. See the image below, which I have repeated some pharmacies, see their CNPJ (06626253003681 and 06626253001476 ). They are repeated because they are on different dates. What I need is that I make a count
in the number of pharmacies and the sum I put in the node Eucerin Hyaluron Night 50mg , that in this example would be 6 and next to each medicine the amount 1. It happens that in my LINQ
I have a ToList()
and this does not allow me to give Count()
. I have a hard time doing this.
See how my screen is:
Seemylinkbelow:
publicstaticList<MontaArvoreAcao>CriarListaArvorePdv(){RupturaEntitiesdb=newRupturaEntities();var_listaPdv=(fromrindb.Rupturajoinaindb.Apresentacaoonr.Codigo_Apresentacaoequals(a.Codigo_Apresentacao)joinmindb.Motivoonr.IDMotivoequals(m.IDMotivo)joinpindb.PDVonr.CodigoPDVequals(p.CodigoPDV)wherer.IDMotivo!=6grouprbynew{p.Cnpj,loja=p.Descricao,a.Descricao,a.Familia,a.Unidade_Negocio,r.IDMotivo,r.DataRuptura}intogrselectnewMontaArvoreAcao{CnpjDescricao=gr.Key.Cnpj+" - " + gr.Key.loja,
Descricao = gr.Key.Descricao,
DataRuptura = gr.Key.DataRuptura,
Familia = gr.Key.Familia,
IDMotivo = gr.Key.IDMotivo,
Unidade_Negocio = gr.Key.Unidade_Negocio
}
).Distinct().ToList().OrderBy(r => r.Descricao);
return _listaPdv.ToList();
}