我有这个问题:
var rowsPerProvider = (from row in dt.Select()
let emp = row["f_name"].ToString().Trim()
group row by emp
into g
select g).ToDictionary(
g => g.Key,
g => g.ToArray());
如何更新它以过滤更多列?例如,目前它在f_name
上。如何将其更新为f_name
和m_name
以及l_name
上的群组?
答案 0 :(得分:3)
使用匿名类:
// (...)
group row by new { emp, something }
答案 1 :(得分:3)
创建一个包含您要分组的字段的匿名对象:
var rowsPerProvider = (from row in dt.Select()
group row by new
{
emp1 = row["f_name"].ToString().Trim(),
emp2 = row["m_name"].ToString().Trim(),
emp3 = row["l_name"].ToString().Trim(),
}
into g
select g).ToDictionary(
g => g.Key,
g => g.ToArray());