0

在 vb.net 中,我有两个数据表,dt1并且dt2. 两者都只有一列。

现在我需要另一个表dt3,其中的行应该dt1不存在于dt2.

我尝试使用 LINQ:

Dim results = From table1 In dt1 
              Join table2 In dt2 On table1(0) Equals table2(0) 
              Select table1(0)  

但是这只返回匹配的。但我需要相反的(行中不存在dt2)。

没有LINQ可以吗?

4

1 回答 1

1

据我了解,您不需要联接(因为您只从第一个表中选择行)。您可以使用 LINQ 查询,例如

From table1 In dt1 _
Where Not (From table2 In dt2 Where table2(0) = table1(0)).Any() _
Select table1(0)
于 2012-09-12T12:47:51.177 回答