【发布时间】:2014-11-11 09:24:55
【问题描述】:
我在处理这个 Linq 查询时遇到了问题。我有一个包含我要处理的所有数据的数据表(包括一个名称列)。我想对此数据表进行 Linq 查询,但我想排除在 myNegativeList 中也可以找到数量 >= 15 的名称。
myNegativeList 有 (Name = "John"; Amount = 5) John 不应从 Linq 查询中排除。 myNegativeList 也有 (Name = "Sally"; Amount = 100) Sally 应从 Linq 查询中排除。
Class ListItems
Public Name As String
Public Amount As Decimal
End Class
Sub GetList()
'get data table
Dim NoticeTable As DataTable = GetTable 'has Name and other data
'get my list of names I don't want
Dim myNegativeList As List(Of ListItems) = getMyList
'Psuedo code here
Dim Cust = From Notice In NoticeTable _
Where Notice.Name not in (Select Name from myList where Amount >= 15)
End Sub
如何进行不包括名称的 Linq 查询(存在于 myNegativeList AND amount >= 15)
【问题讨论】:
-
尽量不要在查询中使用“not”运算符
-
@SantoshaEpili 你应该not不要在VB中使用“not”运算符:)