C# linq使用分组group

           (from a in allStockList
                                  group a by new { a.GoodsId, a.SkuId }
                into g
                                  select new XYHL.Models.Store.Stock()
                                  {
                                      GoodsId = g.Key.GoodsId,
                                      SkuId = g.Key.SkuId,
                                      TotalBuy = g.Sum(a => a.TotalBuy),
                                      TotalSale = g.Sum(a => a.TotalSale)
                                  }).ToList();                

 

posted @ 2022-08-06 14:29  木子zzgxl  阅读(511)  评论(0编辑  收藏  举报