我有这个:我有三个列表,其中包含数据订单订单行和地址。
我想加入这些名单。
Contents = from o in Orders
join a in addresses on o.DeliveryAddressId equals a.AddressId
//join ol in ordersLines on o.OrderId equals ol.OrderId
let ol = ShopOrderLines.Where(x=>x.OrderId == o.OrderId)
select new Order
{
OrderId = o.OrderId,
CreatedDate = o.CreatedDate,
Status = o.Status,
CustomerComment = o.CustomerComment,
AdminComment = o.AdminComment,
PaymentType = (PaymentType) o.PaymentStatus,
PaymentStatus = (PaymentStatus) o.PaymentType,
Firstname = a.Firstname,
Lastname = a.Lastname,
Sum = ol.Any() ? ol.Sum(x=>x.Quantity * x.Price) : 0
};
这很好用,但我还想为每个订单添加 orderLines 的总和。
像这样的东西。sum = (ol.Vat * ol.Quantity) + (ol.Quantity + ol.Price)
我想我必须对结果进行分组然后计算`?
任何人?