I am having a list myTask, in which I want to do a group by Date and calculate the total per date on the Amount.
How can I do that?
public class Task{
public DateTime Date{get;set;}
public string Item {get;set;}
public decimal Amount {get;set;}
}
public List<Task> taskList{ get; set; }
I suspect you want:
Or in one go:
Note that this is assuming the
Dateproperty really is a date rather than a timestamp. Otherwise you might wantx => x.Date.Dateas the first argument.If this isn’t what you’re after, please say how it differs from what you want.
EDIT: Okay, if you want the items as well – but presumably not the date with each item – you can write: