向组by语句添加更多项
本文关键字:添加 by 语句 向组 | 更新日期: 2023-09-27 18:14:09
我有这样的查询:
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
上的组?
创建一个包含您想要分组的字段的匿名对象:
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());
使用匿名类:
// (...)
group row by new { emp, something }