-1

I don´t know where is the mistake why it says that does not contain a defintion of ImporteSolicitado, interesesDemora and importeReintegro when they are colums of c and the last one of d

var importes = (from c in _context.ReintegroSolicitado
                join d in _context.ReintegroRecibido on c.Expediente.ID equals d.Expediente.ID 
                group new {c,d} by new { c.Expediente.Codigo} into cd
                select new { ImporteSolictadoFinal = cd.Sum(b => b.ImporteSolicitado + b.InteresesDemora), ImporteReintegroFinal = cd.Sum(e => e.ImporteReintegro) });
ekad
  • 14,436
  • 26
  • 44
  • 46

2 Answers2

1

your group element contains two property c and d. So you need refer to this property as

...
select new { 
    ImporteSolictadoFinal = cd.Sum(b => b.c.ImporteSolicitado + b.c.InteresesDemora),
    ImporteReintegroFinal = cd.Sum(e => e.d.ImporteReintegro) }
...
parfilko
  • 1,308
  • 11
  • 12
  • Hi, this solution I tried but when they execute this, the var has not value, has this error Static members = error CS0119: 'ArgumentException' is a type, which is not valid in the given context. Another point is that i want to show expediente.codigo too. Thanks you – Gabriel Rubio Palacios Jul 03 '17 at 15:57
0

This is very tough to get right with query posted. I did my best, but it is probably not exactly correct.

           var importes = (from c in _context.reintegroSolicitado
                            join d in _context.reintegroRecibido on c.expediente.ID equals d.expediente.ID
                            select new { reintegroSolicitado = c, reintegroRecibido = c})
                            .GroupBy(x => new { c = x.reintegroSolicitado , d = x.reintegroRecibido})
                            .Select(cd => new { ImporteSolictadoFinal = cd.Sum(b => b.reintegroSolicitado.ImporteSolicitado + b.reintegroSolicitado.InteresesDemora), ImporteReintegroFinal = cd.Sum(e => e.reintegroRecibido.ImporteReintegro) });

        }

    }
    public class Context
    {
        public List<ReintegroSolicitado> reintegroSolicitado { get; set; }
        public List<ReintegroSolicitado> reintegroRecibido { get; set; }
        public Expediente expediente { get; set; }
    }
    public class ReintegroSolicitado
    {
        public Expediente expediente { get; set; }
        public int ImporteSolicitado { get; set; }
        public int InteresesDemora { get; set; }
        public int ImporteReintegro { get; set; }
    }
    public class Expediente
    {
        public int ID { get; set; }
        public int Codigo { get; set; }
    }
jdweng
  • 33,250
  • 2
  • 15
  • 20
  • Hi, I try your answer but is not exactly correct, because I don´t show expediente.codigo, so i can´t see if the results are correct by the group by, i think yes but is not totally complete. Thanks for your help – Gabriel Rubio Palacios Jul 03 '17 at 15:59