Name No Qty
A 1 50
A 2 60
B 12 10
C 13 70
Result:
A 1,2 110
B 12 10
C 13 70
var groupResult = data.ToLookup(s => s.Name);
string symbol=",";
foreach (var c in groupCPSPNResult)
{
result.Add(new
{
Name= c.Key.Name,
No= string.Join(symbol, c.Select(s => s.No).ToArray()),
Total= c.Sum(s => s.Qty)
});
}
參考資訊:
http://www.dotblogs.com.tw/dyco/archive/2010/08/25/17401.aspx