I have 2 data tables with similar data but totally different id fields. the data columns have different names too This is what I mean:
Table1
id dataIn1
010 Data000
123 Data1
222 Data2
323 Data4
443 Data6
Table2
id dataIn2
551 Data1
676 Data2
111 Data3
625 Data4
444 Data5
665 Data6
I want a new DataTable3 that has data in Table2 but not in Table1. Note that there is a row in Table1 not in Table2 as well but I don't care about it.
Table3
id dataIn3
111 Data3
444 Data5
I have tried these approaches:
tb2.Merge(tb1);
DataTable tb3 = tb2.GetChanges();
But tb3
returned null
And this returned a datatable but the rows were wrong
var notIn1 = tb2.AsEnumerable().Select(r => r.Field<string>("dataIn2"))
.Except(tb1.AsEnumerable().Select(r => r.Field<string>("dataIn2")));
DataTable tb3 = (from row2 in tb2.AsEnumerable()
join row3 in notIn1
on row2.Field<string>("dataIn2") equals row3
select row2).CopyToDataTable();