best way to parse dates into month blocks
Given x amount of dates and the fiscal month being 1st-31st:
What's the best way to gr开发者_JAVA技巧oup the months. For example,
a date range of Jan 15 - Feb 15 are considered 2 items
var dateGroups = myDates.GroupBy(d => d.Month);
and as brought up, years would be useful
var dateGroups = myDates.GroupBy(d => d.Month)
.Select(g => new {year = g.Key, monthGrouping = g.GroupBy(d => d.Month)})
.SelectMany(a => a.monthGrouping
.Select(g => new {a.year, month = g.Key, dates = g.AsEnumerable()}));
精彩评论