不能將類型
'System.Collections.Generic.List<AnonymousType#1>'
隱式轉換爲'System.Collections.Generic.IEnumerable<System.Data.DataRow>'
。一個顯式轉換存在(是否缺少強制轉換?)C#不能隱式轉換類型'System.Collections.Generic.List <AnonymousType#1>'
我有兩個數據表稱爲數據2,數據3, 我想將數據輸入到數據3 group by後。 如何修改我的代碼?
IEnumerable<DataRow> temp = (from p in Data2.AsEnumerable()
group p by new
{
ID = p.Field<string>("ID"),
StyleID = p.Field<string>("StyleID"),
BrandID = p.Field<string>("BrandID"),
SeasonID = p.Field<string>("SeasonID"),
Article = p.Field<string>("Article"),
PatternCode = p.Field<string>("PatternCode")
} into g
select new
{
ID = g.Key.ID,
StyleID = g.Key.StyleID,
BrandID = g.Key.BrandID,
SeasonID = g.Key.SeasonID,
Article = g.Key.Article,
PatternCode = g.Key.PatternCode,
QTY = g.Sum(p => p.Field<int>("QTY"))
}).ToList();
Data3 = temp.CopyToDataTable();
謝謝你的幫助 –