1
Dim x = From row In f_table.AsEnumerable()
                    Select row("Crop")

据我了解,“f_table.AsEnumerable”应该使我的搜索对象(在这种情况下为“行”)成为数据行对象。这个简单的示例运行时没有任何异常,但没有找到任何条目(如果我切换到从 f_table 获取的数据行数组,而不是 f_table.AsEnumerable,则此搜索有效)。

任何想法为什么 AsEnumerable 不允许搜索表的行?

编辑/添加:以下是我所拥有的,其中“emptyrows”是 f_table 中行的子集数组。

Dim emptyrows_grouped = From row In emptyrows
                                Order By row("Date"), row("Time")
                                Group By New With {.date = row("Date")}.date,
                                         New With {.crop = row("Crop")}.crop
                                Into Group

我想要的是这种形式:

Dim emptyrows_grouped = From row In f_table.AsEnumerable
                                Where row.Field(Of String)("SamplePosition") Like "Emp%"
                                Order By row("Date"), row("Time")
                                Group By New With {.date = row("Date")}.date,
                                         New With {.crop = row("Crop")}.crop
                                Into Group
4

2 回答 2

5

它是这样工作的:

 Dim query = dt.AsEnumerable
             .Where(Function(dr) dr("column name").ToString = "something").ToList

这会产生一个 DataRows 列表,其中该列的值为“某物”

通过...分组:

 Dim query = dt.AsEnumerable
             .Where(Function(dr) dr("column name").ToString = "something")
             .GroupBy(Function(dr) dr("column name"))
于 2014-06-28T17:01:16.720 回答
-1

没关系 - 我今天是个大傻瓜,因为 f_table 是错误的数据表。我用了正确的,它奏效了。

Dim emptyrows_grouped = From row In file_table.AsEnumerable
                                Where row.Field(Of String)("SamplePosition") ="Empty"
                                Order By row("Date"), row("Time")
                                Group By New With {.date = row("Date")}.date,
                                         New With {.crop = row("Crop")}.crop
                                Into Group

请原谅我浪费你的时间!!

于 2014-06-28T18:27:18.750 回答