不能将类型
'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();
谢谢你的帮助 –