I have an event table. And each POS is an event, with Event ID, Date, User and Type. Well, whenever I make an appointment, I populate an event grid. I would like to know how to bring the last five with LINQ and / or Lambda to a same CNPJ?
Is this code correct?
var result_evento = (from ev in db.T_CRM_Evento
select new { ev.ID_CRM_Evento, ev.DE_Usuario, ev.ID_TipoEvento, ev.DT_Inclusao})
.Take(5)
.Max(evento => evento.DT_Inclusao);
This linq worked. Moved with my layout, but deyu sure. At least in terms of the bank's bottom line, it worked.
var result_evento = (from ev in db.T_CRM_Evento
.Where(e => e.DE_CNPJ == carregagrid.Cnpj)
select new { ev.ID_CRM_Evento, ev.DE_Usuario, ev.ID_TipoEvento, ev.DT_Inclusao })
.Take(5)
.OrderByDescending(dt => dt.DT_Inclusao);