Reputation: 1731
In vb.net I have two datatables, dt1
and dt2
. Both have only one column.
Now I need another table dt3
which should have the rows of dt1
that are not present in dt2
.
I tried to do with LINQ:
Dim results = From table1 In dt1
Join table2 In dt2 On table1(0) Equals table2(0)
Select table1(0)
But this returns only that are matching. But I need the opposite (rows not there in dt2
).
Is it possible doing without LINQ?
Upvotes: 0
Views: 1689
Reputation: 121912
As far as I understand, you don't need a join (as you are selecting only rows from the first table). You can use a LINQ query like
From table1 In dt1 _
Where Not (From table2 In dt2 Where table2(0) = table1(0)).Any() _
Select table1(0)
Upvotes: 1