linq group by 多条件并返回原数据。
C# code
(from p in qList
group p by
new { p.itemCode, p.City, p.VcCode }
into g
select new
{
q_count = g.Sum(p=>p.iSampleCount),
q_price = g.Sum(p=>p.iPrice),
q_amt = g.Sum(p=>p.iAmt),
q_itemCode = //这里我想得到p.itemCode
}).ToList();
请问这里该怎么写才能得到需要的值?
------解决方案--------------------C# code
(from p in qList
group p by
new { p.itemCode, p.City, p.VcCode }
into g
select new
{
q_count = g.Sum(p=>p.iSampleCount),
q_price = g.Sum(p=>p.iPrice),
q_amt = g.Sum(p=>p.iAmt),
q_itemCode = g.Key. itemCode
}).ToList();
------解决方案--------------------q_itemCode = g.Key.itemCode