【发布时间】:2016-03-17 18:23:55
【问题描述】:
我的数据库中有订单,每个订单都有一组津贴。与订单相关的 Allowance 有一个 ChargeIndicator 来表示它是折扣 (0) 还是非折扣 (1)。
对于某个时间段,我需要该时间段内使用的折扣,以及使用每个折扣的订单总和。
我可以获取已使用折扣的列表,但无法返回订单获取汇总信息
var discounts = this.Repository.GetOrders()
.Where(o =>
o.AllowanceCharge.Any(ac => !ac.ChargeIndicator) &&
o.IssueDate > DateTime.Now.AddDays(-10) &&
o.IssueDate < DateTime.Now.AddDays(-1))
.SelectMany(o => o.AllowanceCharge.Where(ac => !ac.ChargeIndicator))
.Discinct()
【问题讨论】: