1
I need to make a count
, for the following situation. See the image below, that I have repeated some pharmacies, see their CNPJ(066253003681 and 06626253001476). They are repeated because they are on different dates. What I need is for me to make a count
in the amount of pharmacies and the sum I put in the knot Eucerin Hyaluron Night 50mg, that in this example would be 6 and next to each medicine the quantity 1. It happens that in my LINQ
I have a ToList()
and that doesn’t allow me to give a Count()
. I have a hard time doing this.
Look at my screen:
See my letter below:
public static List<MontaArvoreAcao> CriarListaArvorePdv()
{
RupturaEntities db = new RupturaEntities();
var _listaPdv = (
from r in db.Ruptura
join a in db.Apresentacao on r.Codigo_Apresentacao equals (a.Codigo_Apresentacao)
join m in db.Motivo on r.IDMotivo equals (m.IDMotivo)
join p in db.PDV on r.CodigoPDV equals(p.CodigoPDV)
where r.IDMotivo != 6
group r by new { p.Cnpj, loja = p.Descricao, a.Descricao, a.Familia, a.Unidade_Negocio, r.IDMotivo, r.DataRuptura } into gr
select new MontaArvoreAcao
{
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();
}
You installed the package Morelinq that I told you in the other answer? You don’t need to use this
Count
.– Leonel Sanches da Silva
already tried to add a property in Montaarvoreacao and associate the value gr. Count?
– Thiago Custodio
I installed Morelinq. As I do now?
– pnet