Dim query = (From row In dataTable.AsEnumerable() _
Where row.Field(Of String)("SomeColumn") = "Y"
Select AnothereDataTable.LoadDataRow(New Object() {row.Field(Of Decimal?)("coloum1"), _
row.Field(Of String)("Column2")},True))
我有上面的linq查询,我在“SomeColumn”上过滤数据表,条件等于“Y”。 “SomeColumn”也可能包含空值,因为当我尝试获取query.Count()时,我得到异常“对象未设置为实例”,但如果“SomeColumn”中没有空值,则查询返回完美。我也试过以下代码,但没有用
Where Object.equals(row.Field(Of String)("SomeColumn")="Y")
Where row.Field(Of String)("SomeColumn").Equals("Y")