I have the below Linq query that is returning the data but I need to aggregate the columns to group on the Period and Sum the Count columns.
How do I go about doing this?
LINQ
from t In tblTimes
join h In tblEngineeringDashboard_CADMachinesCounts on t.ID Equals h.TimeID
Order By t.Period
Group By t.Period, h.Count Into Group
select Period, Count
DATA
Period CountΞΞ
01/01/2010 00:00:00 0
01/01/2010 00:00:00 1
01/01/2010 00:00:00 2
01/01/2010 00:00:00 3
01/01/2010 00:00:00 5
01/01/2010 00:00:00 6
01/01/2010 00:00:00 7
01/01/2010 00:00:00 9
01/01/2010 00:00:00 11
01/01/2010 00:00:00 12
01/01/2010 00:00:00 14
01/01/2010 00:00:00 15
01/01/2010 00:00:00 17
01/01/2010 00:00:00 21
01/01/2010 00:00:00 22
01/01/2010 00:00:00 30
01/01/2010 00:00:00 31
01/01/2010 00:00:00 34
01/02/2010 00:00:00 0
01/02/2010 00:00:00 1
01/02/2010 00:00:00 2
01/02/2010 00:00:00 3
01/02/2010 00:00:00 5
01/02/2010 00:00:00 6
01/02/2010 00:00:00 7
01/02/2010 00:00:00 9
01/02/2010 00:00:00 12
01/02/2010 00:00:00 14
01/02/2010 00:00:00 15
01/02/2010 00:00:00 17
01/02/2010 00:00:00 21
01/02/2010 00:00:00 23
01/02/2010 00:00:00 30
01/02/2010 00:00:00 34
etc
Assuming you have retrieved your records from the database into an enumerable variable named ‘PeriodRecords’ you could use the following Linq statement to get the individual periods and the sum of count per period.
You can then iterate over your new “countsPerPeriod” variable as follows;