0
I am trying to group the objects of a list by month or year, before returning the same.
I am trying this way and I did not succeed.
foreach (var item in passList)
{
pass_obj = new Pass_returnDTO();
pass_obj.pass_date_time = item.pass_date_time.Date;
pass_obj.qty_pass = Convert.ToInt32(item.qty_daily_pass);
listRegistro.Add(pass_obj);
}
if (grouper == "ano")
{
objReturn.registros.GroupBy( d => d.pass_date_time.Year);
listPassReturn.Add(objReturn);
}
else if (grouper == "mes")
{
objReturn.registros.GroupBy(d => d.pass_date_time.Month);
listPassReturn.Add(objReturn);
}
Already solved? In case you have not solved, you want to group by year and month and have the amount of records per grouping? It would be like: 2019-09 - quantity = 10, 2019-08 - quantity = 20...
– Raquel Pinheiro
Hello @Raquelpinheiro, already got it, thank you very much!
– iago soares