I have two datatables which might have rows more than 800k. I wanted to compare both the tables and take out the rows which were in DT1 and not in DT2 so I used
which was running fine but as except function returns only UNIQUE values so now post the result is coming duplicate values are vanishing up But i need the complete data without duplicate removal.
Can anyone help with an alternative approach or solution for the problem.
dt1 = dt1.AsEnumerable.OrderBy(Function(r) String.Join(chr(9),r.ItemArray)).CopyToDataTable
dt2 = dt2.AsEnumerable.OrderBy(Function(r) String.Join(chr(9),r.ItemArray)).CopyToDataTable
Dim idx1 As Int32 = dt1.Rows.Count-1
Dim idx2 As int32 = dt2.Rows.Count-1
While (idx1>=0 AndAlso idx2>=0)
If (String.Join(chr(9),dt1.Rows(idx1).ItemArray)=String.Join(chr(9),dt2.Rows(idx2).ItemArray) )
dt1.Rows.RemoveAt(idx1)
idx1=idx1-1
ElseIf (String.Join(chr(9),dt1.Rows(idx1).ItemArray)>String.Join(chr(9),dt2.Rows(idx2).ItemArray))
idx1=idx1-1
Else
idx2=idx2-1
End If
End While
Because the above expression concatenate each items with tab (Chr(9)) for evaluating. If your data includes tab, for example, A[tab]B , C and A , B[tab]C both will be A[tab]B[tab]C and there is possibility we cannot evaluate their equality.
I tried running the invoke code but it not returning me correct result
As -
Limited set of data the above code suggested is giving me only 1 row which is correct but when I am using the new invoke code approach that is giving me 16 rows which is not correct and my data does not have TAB.
I am trying to prepare a dummy data but on the dummy data the invoke code is working fine though. It is not working on actual data where the LINQ queries you provided was working fine.