-3
我有一個C#代碼如下,它在IEnumerable<\u003C\u003Ef__AnonymousType0
顯示錯誤有人可以告訴我如何解決它。需要解決的C#錯誤u003Ef__AnonymousType0
dataSet = this.GetData.getInfo("SELECT b.nBatchID, td.F_Name &' '& td.M_Name &' '& td.L_Name AS StaffName, b.BatchName FROM (Batch AS b LEFT JOIN BatchTrainer AS bt ON b.nBatchID = bt.nBatchId) LEFT JOIN TrainerDetails AS td ON bt.TrainerId = td.TrainerID", "Batch");
IEnumerable<\u003C\u003Ef__AnonymousType0<object, string, string>> datas = dataSet.Tables[0].Copy().AsEnumerable().GroupBy<DataRow, object>((Func<DataRow, object>) (row => row["nBatchId"])).Select(g =>
{
var data = new{ id = g.Key, text = string.Join(",", g.Select<DataRow, string>((Func<DataRow, string>) (r => r["StaffName"].ToString())).ToArray<string>()), Batch = g.Select<DataRow, string>((Func<DataRow, string>) (r => r["BatchName"].ToString())).FirstOrDefault<string>() };
return data;
});
table.Columns.Add("nBatchId", typeof (int));
table.Columns.Add("StaffName", typeof (string));
table.Columns.Add("BatchName", typeof (string));
foreach (var data in datas)
table.Rows.Add(data.id, (object) data.text, (object) data.Batch);
dataSet.Tables.Clear();
dataSet.Tables.Add(table);
爲什麼,哦爲什麼你的代碼中有'IEnumerable <\ u003C \ u003Ef__AnonymousType0 <對象,字符串,字符串>>? –
不要將代碼從反編譯器中複製粘貼。他們不一定會生成正確的代碼。 –