I want to get a sales list for each month ordered by the product.
I currently have the following linq request:
var query = storeDB.OrderDetails
.Select(od => od)
.GroupBy(r => r.Product)
.Select(group => new ProductSalesModel {
Product = group.Key,
Sales = group.Sum(s => s.Quantity),
Amount = group.Sum(s => s.Quantity * s.UnitPrice)
})
.OrderByDescending(x => x.Amount);
How can I do to also group the list by month, getting the sale date from my order table? Order.CreationDate?
source
share