Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net LINQ-左连接以查找不匹配的记录_Vb.net_Linq - Fatal编程技术网

Vb.net LINQ-左连接以查找不匹配的记录

Vb.net LINQ-左连接以查找不匹配的记录,vb.net,linq,Vb.net,Linq,我试图在两个数据表之间执行一个左联接,该联接将返回左表中的所有记录,而右表中的联接条件没有相应的值。到目前为止,我有以下内容,但不返回任何内容: Dim Query1 = From exasset In dtExistingAssets _ GroupJoin asset In dtNewAssets _ On exasset("ACCOUNT_NAME") Equals asset("ACCOUNT_NAME") _

我试图在两个数据表之间执行一个左联接,该联接将返回左表中的所有记录,而右表中的联接条件没有相应的值。到目前为止,我有以下内容,但不返回任何内容:

Dim Query1 = From exasset In dtExistingAssets _
             GroupJoin asset In dtNewAssets _
             On exasset("ACCOUNT_NAME") Equals asset("ACCOUNT_NAME") _
             Into results = Group _
             From f In results.DefaultIfEmpty _
             Where IsDBNull(f) _
             SelectNewWith _
             { //...

我已经看到了一些关于使用
Any
的引用,但是我无法获得正确的语法。有人能帮忙吗?这在SQL中很容易实现,但在LINQ中似乎要复杂得多。

我会使用强类型的
DataRow
扩展方法,比如也支持空值

Dim query = From exAsset In dtExistingAssets
        Group Join newAsset In dtNewAssets
        On exAsset.Field(Of String)("ACCOUNT_NAME") Equals newAsset.Field(Of String)("ACCOUNT_NAME") Into Group
        From joinedAssets In Group.DefaultIfEmpty()
        Where joinedAssets.Field(Of String)("ACCOUNT_NAME") Is Nothing
如果您只想了解新客户,您还可以使用以下有效工具:


我认为问题在于
IsDBNull(f)
,左连接将导致空值(
Nothing
在VB中)而不是
DBNull
值。我想你应该把它改成:``

...
From f In results.DefaultIfEmpty _
Where f is Nothing
...
From f In results.DefaultIfEmpty _
Where f is Nothing