标签:var 图片 col div data purchase fir tle err
1 原始数据
2 写法
var data1 = _m.GetPurchase_Title(MasterId).FirstOrDefault();//表头 var data2 = _m.GetPurchaseDt(MasterId);//明细 var result = new { PurNo = data1.MasterId, ProviderName = data1.ProvideName, Remark = data1.Remark, SumCount = data1.preQty, SumMoney = data1.OMoney, Detail_style = data2.GroupBy(m => m.style).Select(g => new { style = g.Key, Detail_Sku = g.Select(n => n) .GroupBy(x => new { x.StyleName, x.SerialNo, x.AttribName, x.ClrName, x.Oprice }) .Select(t => new { preQty = t.Sum(b => b.preQty), OPrice = t.Key.Oprice, OMoney = t.Sum(b => b.OMoney), StyleName = t.Key.StyleName, SerialNo = t.Key.SerialNo, AttribName = t.Key.AttribName, ClrName = t.Key.ClrName, Size = t.Select(v => v).GroupBy(z => z.SizeName).Select(k => k.Key + ":" + k.Sum(l => l.preQty).ToString()) }) }) };
3 效果:
{ "errmsg": "ok", "PurNo": "B201709270000019", "ProviderName": "外4Q-37615林志峰", "Remark": "这是一段牛逼的备注", "SumCount": 100, "SumMoney": 2400.00, "Detail_style": [{ "style": "10B73A33980", "Detail_Sku": [{ "preQty": 8, "OPrice": 100.00, "OMoney": 2400.00, "StyleName": "这是品名", "SerialNo": "原厂编号", "AttribName": "专柜", "ClrName": "大红", "SizebName": ["36:10", "37:10", "38:20", "L:30", "XLL:100"] }, { "SkuCount": 9, "OPrice": 100.00, "OMoney": 2400.00, "StyleName": "这是品名", "SerialNo": "原厂编号", "AttribName": "专柜", "ClrName": "绿", "SizebName": ["X:10", "XX:10", "XXL:20", "L:30", "XLL:100"] }] }, { "style": "20B73A33981", "Detail_Sku": [{ "SkuCount": 10, "OPrice": 100.00, "OMoney": 2400.00, "StyleName": "这是品名", "SerialNo": "原厂编号", "AttribName": "专柜", "ClrName": "颜色", "SizebName": ["X:10", "XX:10", "XXL:20", "L:30", "XLL:100"] }, { "SkuCount": 11, "OPrice": 100.00, "OMoney": 2400.00, "StyleName": "这是品名", "SerialNo": "原厂编号", "AttribName": "专柜", "ClrName": "颜色", "SizebName": ["X:10", "XX:10", "XXL:20", "L:30", "XLL:100"] }] } ] }
标签:var 图片 col div data purchase fir tle err
原文地址:https://www.cnblogs.com/zoumin123/p/9025963.html