0

我有这个:我有三个列表,其中包含数据订单订单行和地址。

我想加入这些名单。

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)

我想我必须对结果进行分组然后计算`?

任何人?

4

1 回答 1

0

我更改了我的代码并添加了 let ol = ShopOrderLines.Where(x=>x.OrderId == o.OrderId) 这给了我一个 List om orderlines 可以使用。

于 2012-06-06T08:38:10.487 回答