Det er nok for komplekst til å dele fornuftig.
Her er de siste stegene i prosessen:
// data.FromDateTime will be converted to local time
electricityConsumedList = electricityConsumedList.Aggregate(
startDateTime,
endDateTime,
unit,
data => DateTimeUtilities.Convert.ToOsloFromUtc(data.FromDateTime),
ElectricityConsumed.Aggregate);
// Find the 3 hours with the largest power consumtion (over different days)
var highestConsumingHours =
(from x in electricityConsumedList
group x by x.FromDateTime.Day into dateGroup
orderby dateGroup.Key
select dateGroup.OrderByDescending(z => z.SumConsumedkWh).FirstOrDefault())
.OrderByDescending(x => x.SumConsumedkWh)
.Take(3)
.ToList();
double averagePeakConsumption = highestConsumingHours.Average(x => x.SumConsumedkWh);