Suppose we have a simplified Orders entity, with this properties: Id (int, PK), orderDate (datetime, not null) and productCategory (string, not null).
What would be the LINQ to Entities query that returns the count of orders for each category, grouped by month, for the past 12 months, ordered by year, month?
The output should look like this, in order to pass it as series for a Highcharts lines chart, using JQuery.getJSON()
:
[{
name: 'Dairy',
data: [23, 27, 32, 44, 21, 30, 11, 0, 9, 24, 3, 19]
},
{
name: 'Frozen',
data: [11, 4, 0, 6, 8, 10, 17, 24, 18, 8, 23, 10]
}]
That is, 12 values for each category, including zeros.