I have this code :
var tradeReqsBySegment = segGroups.Join(pPeriods, s => s.MarketSegmentId, p => p.EntityId, (s, p) => new
{
SegmentCode = s.SegmentCode, // string
Time = p.StartLocal, // datetime
TradeRequirement = p.Volume // double
})
.GroupBy(s => s.SegmentCode)
.ToDictionary(g => g.Key, g => g.ToDictionary(i => i.Time, i=>i.TradeRequirement));
我希望
g.ToDictionary(i => i.Time, i=>i.TradeRequirement))
根据时间分组,TradeRequirement
求和或求平均。我该怎么做?此外,是否可以按月分组时间,例如获取:
Time - TradeReq
01/2013 - 500
02/2013 - 234
...