i have 2 datatables tables which have the same columns but with different data and some times there are rows the share the same ID
i want to join those to table where ID of some row in table2 doesn’t exist in table1
so if i the following tables
ID Name
1 A
2 B
3 C
ID Name
5 D
1 A
2 B
3 C
the from joining would be
ID Name
1 A
2 B
3 C
5 D
here is what i tried
Dim q = From e In tbl1.AsEnumerable Join r In tbl2.AsEnumerable On e.Field(Of Integer)("id") Equals r.Field(Of Integer)("id")
but no idea on how do i get this to a datatable
LINQ is not all that good in working with
DataTablebut you could do something like this:You need to create an
IEqualityComparerto define how to compareDataRows. I decided to compare only theirIdvalue but you could compare every column in a similar manner: