Q:
id name
1 t
2 t
3 c
期望结果
{"1,2","t"}
{"3","c"}
方法如下:
var result = from item in tbl
group item by item.name into g
let ids = g.Select(b => b.id.ToString()).ToArray()
select new { id = String.Join(",", ids), name = g.Key };
Q:
id name
1 t
2 t
3 c
期望结果
{"1,2","t"}
{"3","c"}
方法如下:
var result = from item in tbl
group item by item.name into g
let ids = g.Select(b => b.id.ToString()).ToArray()
select new { id = String.Join(",", ids), name = g.Key };