I have the following class:
internal class ModuleScrap
{
public System.DateTime ReadTime { get; set; }
public string ScrapReason { get; set; }
public Int16 NetScrap { get; set; }
}
I could use some help with a LINQ query that retrieves all rows between a range of dates (that’s the easy part), groups on ScrapReason and determines the sum of NetScrap for each group. I don’t have much experience with grouping in LINQ.
Something like this, I suspect:
Note that the
intcast is becauseSumisn’t defined forInt16values. An alternative is to change the grouping:They’ll give the same results – it’s just a matter of which you prefer.