我有 DataTable 对象(OutputDT1
),我想使用 LINQ 按列分组ConfirmedBy
,然后将其转换回DataTable
只有两列ConfirmBy
和Count
.
var result = from row in OutputDT1.AsEnumerable()
group row by new
{
ConfirmedBy = row.Field<string>("ConfirmedBy")
}
into grp
select new
{
ConfirmedBy = grp.Key.ConfirmedBy,
Count = grp.Count(),
};