任何人都可以帮我完成这项工作吗?
我有以下代码:
dt.Columns.Add("Field1", typeof(String));
dt.Columns.Add("Field2", typeof(String));
dt.Columns.Add("NR", typeof(Double));
dt.Rows.Add("A", "990001", 100);
dt.Rows.Add("A", "990001", 120);
dt.Rows.Add("B", "990001", 200);
dt.Rows.Add("B", "990001", 300);
var fields = new List<string>() { "Field1", "Field2" };
var q = dt.AsEnumerable().AsQueryable()
.GroupBy("new(" + qfields + ")", "it")
.Select("new(Key as Group, Sum(NR) as Tot)");
当我执行此代码时,我收到错误:
“DataRow”类型中不存在属性或字段“NR”
我需要结果为:
A, 990001, 220
B, 990001, 500