2017-06-20 61 views
0

我有'dtTopAll'的數據表,它有Event和Waits Columns。我想要的是總和等待列和事件組。當我使用金額時得到一個錯誤

但是,下面的代碼會拋出像'等待'列不屬於表的錯誤。

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

如何填充dtTopAll?這聽起來像你沒有一個名爲「等待」的列 - 也許你給它一個別名,或填充表沒有命名列? –

+0

發佈您的數據表代碼。你的發佈代碼看起來不錯 – Rahul

回答

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; 
相關問題