I am using Entity Framework and LINQ. I have a list called "DatosCalc" values ​​are obtained from a filtered by date and identifier input and ordered by date base. The following code:

    List<Registro> datosCalcA = new List<Registro>(); 
    MonitoreoEntities _context = new MonitoreoEntities();

   datosCalcA= _context.Registroes.Where(a => a.PuntoDeMedicionId == pPuntoDeMedicionId
                      && a.EntradaSalidaId == _operadorA
                      || a.EntradaSalidaId == _operadorB
                      && a.FechaHoraRegistro <= _fechaHoraFinal
                      && a.FechaHoraRegistro >= _fechaHoraInicial).OrderBy(i => i.FechaHoraRegistro).ToList();

I get this:

FechaHoraRegistro 12/05/2014 1:52:07 PM} {System.DateTime
ID 1 decimal
Decimal value 29

FechaHoraRegistro 12/05/2014 1:52:07 PM} {System.DateTime
ID 2 decimal
Decimal value 24

FechaHoraRegistro 12/05/2014 2:03:14 PM} {System.DateTime
ID 1 decimal
Decimal value 24

FechaHoraRegistro 12/05/2014 2:03:14 PM} {System.DateTime
ID 2 decimal
Decimal value 25
.............
+ Raw View
+ DatosCalcA Count = 2767 System.Collections.Generic.List <SystemaControl.Registro>

To group by date, I create a new list using GroupBy ()

newList var = datosCalcA.GroupBy (i => i.FechaHoraRegistro) .ToList ();

In this case brings me the dates correctly, newList I have dates, but not the values ​​and need. And what I get is a list grouped by date

FechaHoraRegistro 12/05/2014 1:52:07 PM} {System.DateTime
Decimal value 29
Decimal value 24

FechaHoraRegistro 12/05/2014 2:03:14 PM} {System.DateTime
Decimal value 24
Decimal value 25

excuse my English

And this solved the problem, I'm looking bad breakpoint, it works correctly. Thank You

Related posts

Recent Viewed