开发者

LINQ Group By problem

开发者 https://www.devze.com 2023-01-12 19:46 出处:网络
I am using VB.NET and DataSets; I have two tables and a relation. I\'m querying the first table, but I can\'t use Group By on any field of the table. Here\'s the error I am seeing:

I am using VB.NET and DataSets; I have two tables and a relation. I'm querying the first table, but I can't use Group By on any field of the table. Here's the error I am seeing:

Definition of method 'G开发者_JAVA百科roupBy' is not accessible in this context

And my code is as follows:

Dim Groups = From n In dataSetTableAsEnumerable _
   Group By n.filedName  Into Group

Thanks for any assistance.


Imports System.Linq on the top of your vb code file.


You need to tell it which thing you're grouping, for example:

 Dim Groups = From n In dataSetTableAsEnumerable _
              Group n By n.filedName  Into Group _
              Select Group

In your case you need Group n By as opposed to just Group By.

0

精彩评论

暂无评论...
验证码 换一张
取 消