我有数据表,这是' dtTopAll'它有事件和等待列。我想要的是总和等待列和按事件分组。
然而,下面的代码会引发错误,例如等待'列不属于表。
ultraGrid1.DataSource = dtTopAll;
var dt1 = (from dr1 in dtTopAll.AsEnumerable()
group dr1 by dr1.Field<string>("Event") into g
select new
{
Event = g.Key,
Waits = g.Sum(z => z.Field<int>("Waits"))
}).ToDataTable();
ugWaitEvent.DataSource = dt1;
答案 0 :(得分:0)
Linq查询区分大小写。你能这样试试吗?
ultraGrid1.DataSource = dtTopAll;
var dt1 = (from dr1 in dtTopAll.AsEnumerable()
group dr1 by dr1.Field<string>("Event") into g
select new
{
EVENT= g.Key,
WAITS= g.Sum(z => z.Field<int>("WAITS"))
}).ToDataTable();
ugWaitEvent.DataSource = dt1;