【发布时间】:2016-11-14 08:22:36
【问题描述】:
我对 Linq 比较陌生,正在尝试按我的 Linq 查询进行分组,但收到不包含字段值的错误。
下面是我的 linq 查询。谁能帮我解决这个问题。
var name = dt1.AsEnumerable()
.Where(p => (int)p["Age"] >= 29)
.GroupBy(p =>p.Field<string>("Role"))
.Select(p => new{ID = p.Field<int>("ID"),Name =p.Field<string>("Name"),Role = p.Field<string>("Role"),Age = p.Field<int("Age")});
【问题讨论】:
-
这里groupbby的目的是什么?
-
请添加更多信息以拥有a complete and verifiable example