需要對DataTable分組求和的語法:VB.net 和C#中還有點不太一樣。最后試了好多方法,要這么寫
我的dataTabel數據:
1 (From p In dataTabel.AsEnumerable() 2 Group By x= New With { Key.a =p.Item("name")} Into Grp = Group Select dataTabel.Clone.LoadDataRow (New Object() 3 {grp(0)(0),grp.Sum(Function ( r ) 4 if(String.IsNullOrEmpty(r("fen").ToString) 5 or String.IsNullOrWhiteSpace(r("fen").ToString),0,Convert.ToDouble(r("fen").ToString)))},False)).CopyToDataTable
最后成功打印: