二段Linq Groupby操作
2018-06-22 04:35:07来源:未知 阅读 ()
var messages = list.GroupBy(p=>p.RefOrderNo,(k,v)=> new {OrderNo = k,SkuInfo = v}) .Select(p => { var item = p.SkuInfo.FirstOrDefault(); return new ReplaceLabelSkuMessage { OrderNo = p.OrderNo, Operation = new WMS.Message.Operation { Operator = item.CreateBy, OperateTime = item.CreateOn }, ReplaceLabelSkuDetail = p.SkuInfo.Select(s => new ReplaceLabelSkuDetail { SKU = s.SKU, Weight = s.Weight, Lenght = s.Lenght, Width = s.Width, Height = s.Height }).ToList() }; });
var request = deliveryList.GroupBy(g => g.DeliveryNo) .Select(delivery => { var item = delivery.FirstOrDefault(); var yewuRequest = new DeliveryTicketShipOutMessage { DeliveryTicketNo = item.DeliveryNo, DeliveryType = TMS.Message.DeliveryTicket.DeliveryType.Logistics, WarehouseCode = item.YewuWarehouseCode, ShipOutWarehouse = item.YewuWarehouseCode, SkuContainers = delivery.GroupBy(g => g.ContainerCode).Select(container => { var containerLine = container.FirstOrDefault(); return new LogisticsDeliveryShipOutCustomerAsnContainerRequest { ContainerId = containerLine.ContainerCode, customerOrderType = TMS.Message.Common.CutomerOrderType.First, TargetWarehouseCode = containerLine.TargetWarehouseCode, CustomerAsnId = containerLine.CustomerAsnId, PalletId = containerLine.PalletId, Weight = new Weight { Value = containerLine.Weight, Unit = WeightUnit.G }, Size = new Packing() { Length = containerLine.Length, Width = containerLine.Width, Height = containerLine.Height, Unit = LengthUnit.CM }, Lines = container.GroupBy(l => l.SKU).Select(line => { return new LogisticsDeliveryShipOutCustomerAsnContainerLineRequest { SKU = line.Key, Quantity = line.Sum(s => s.PackingQty), AccountNo = line.FirstOrDefault().CustomerCode }; }).ToList(), Bags = container.Where(p => p.BagCode.Length > 0).GroupBy(g => g.BagCode).Select(bag => { var bagid = bag.Key; return new LogisticsDeliveryShipOutCustomerAsnContainerBagRequest { BagId = bagid, Lines = bag.Select(bagline => new LogisticsDeliveryShipOutCustomerAsnContainerBagLineRequest { SKU = bagline.SKU, Quantity = bagline.PackingQty, AccountNo = bag.FirstOrDefault().CustomerCode }).ToList() }; }).ToList() }; }).ToList(), OperateBy = item.CreateBy, OperateOn = item.CreateOn }; return yewuRequest; }).ToList();
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:走进 .Net 单元测试
- LinQ是什么? 2018-06-22
- Linq 处理 List数据 2018-06-22
- C# linq to xml 简单示例 2018-06-22
- LINQ的查询标准操作汇总 2018-06-22
- 开始写博客,学习Linq 2018-06-22
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash