按多列分组 - LINQ
我见过按列乘法分组的例子,但是对于类。我正在尝试为 EnumerableDataRowList 执行此操作。但我得到“无效的匿名类型成员声明符”。
EnumerableDataRowList<DataRow> enumerableRowCollection = new EnumerableDataRowList<DataRow>(reportData.Select("WeekKey <> '0'"));
var groupedRows1 = from row in enumerableRowCollection
group row by new {row["NETWORK"], row["Week"] };
另外,我看到有些人在某些情况下组合列以获得相同的结果。这样做有什么好处
I have seen examples of multiply group by columns, but for classes. I am trying to do this for a EnumerableDataRowList. but I get "Invalid anonymous type member declarator."
EnumerableDataRowList<DataRow> enumerableRowCollection = new EnumerableDataRowList<DataRow>(reportData.Select("WeekKey <> '0'"));
var groupedRows1 = from row in enumerableRowCollection
group row by new {row["NETWORK"], row["Week"] };
also, I seen some people combine the columns in some case to get the same results. Any benefit in doing it that way
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须为值分配一个标识符:
如果您使用字段或属性引用,通常不需要指定标识符,因为它只会重用该成员的名称 - 但在这种情况下您正在访问索引器属性,因此无法从中获取名称。
You have to assign an identifier to the values:
You normally aren't required to specify an identifier if you're using a field or property reference as it'll just reuse the name of that member - but in this case you're accessing an indexer property, so there's no way to get a name from it.