I have logic problem which I cannot resolve.
I have two datables with number values.
Let`s say:
dt.A
111
222
333
dt.B
111
333
444
I want to keep in new datable result, when searched value from dt.A is not present in dt.B, but, i`m not sure how to do this. When im joing datables with operation not equal(!=)
And well thats correct result, because when its comparing(!=) “111” from dt.A with “444” from dt.B it will be true 111!=333 and then i will get that recorded added to my new DT . What i want to aquire is:
New.DT(expected)
dt.A(value not present in dt.B)
222 (only 222 because value not found in dt.B)
Maybe it`s simple, but i just stuck here and cannot go on :<
Correct me if I am wrong, but you want to create a DataTable where the values in DtA are not present in DtB right?
If that is the case, you can use a Group Join like so →
(From r1 In dtA.AsEnumerable()
Group Join r2 In dtB.AsEnumerable()
On [ConditionGoesHere] Into gj = Group
From g In gj.DefaultIfEmpty()
Where IsNothing(g)
Select r1).CopyToDataTable()
(From d1 In dt1.AsEnumerable
From d2 In dt2.AsEnumerable
Where Not d1(0).toString.Equals(d2(0).toString.Trim)
Let ra = New Object(){d1(0), d2(0)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable