我遇到了以下 LINQ 查询的问题,该查询在帖子标题中引发了异常:
Dim test = From Match In _
(From Load In dtContacts _
Group Join Siebel In dtSiebel _
On Load("Email") Equals Siebel("EMAIL_ADDRESS") _
Into g = Group _
From LoadResults In g.DefaultIfEmpty _
Where Not LoadResults Is Nothing _
Select Email_Address = Load.Field(Of String)("Email"), _
Load_Account_Number = Load.Field(Of String)("AccountNum")) _
Group Join Acct In dtSiebel _
On Match.Email_Address Equals Acct("EMAIL_ADDRESS") _
And Not Match.Load_Account_Number Equals Acct("ACCOUNT_NUMBER") _
Into h = Group _
From MatchResults In h.DefaultIfEmpty _
Where Not MatchResults Is Nothing _
Select Contact_Row_ID = MatchResults.Field(Of String)("CONTACT_ROW_ID"), _
Match.Email_Address, _
Match.Load_Account_Number, _
Account_Num_Chk = MatchResults.Field(Of String)("ACCOUNT_NUMBER")
罪魁祸首是这一行:
And Not Match.Load_Account_Number Equals Acct("ACCOUNT_NUMBER")
对我来说没有意义的是,如果我删除了 'Not' 子句(我用于另一个用例)而保留查询的其余部分不变,我会得到预期的结果而没有任何异常。这里有什么问题?