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();