Compare columns of different datatables using LINQ

Hi Community

There are two datatables with different set of columns
image
image

I need to check whether both the DT_SKU and SiteSKU column in both the datatables match or not. Their order can be different as i am extracting one from the website. They just have to contain same values in both the datatables. If they match then i can proceed further. How can i check this please help??
Any help would be greatly appreciated.

Hey @Aditya_Kumar3

I see Join DataTable will be a good option to go !

Thanks
#nK

Can you please elaborate the steps involved

Hey @Aditya_Kumar3

You need to first perform Join Data Table activity with inner join type

Then check if all the rows are still present from the above result, If yes you have a perfect match else there is some mismatch !

Hope this helps

Thanks
#nK

@Aditya_Kumar3 you can also try Except option, provided you know which data table has more rows.

eg.
dt1 has more rows and dt2 has lesser rows
below query will catch all the missing rows in dt1 which are not there in dt2

dt1.AsEnumerable.Select(function(x) x("Col_A")).except(dt2.AsEnumerable.Select(Function(y) y("Col_B"))).ToList

@Aditya_Kumar3

  • Read the first excl to a data table (DT) and another excel to a data table (DT1)
  • The below exp return false if there is common values and return true if there is a even single uncommon value
Var of type Boolean Output = DT.AsEnumerable.Except(DT1.AsEnumerable, System.Data.DataRowComparer.Default).Any

Please find attached workflow below

Example.zip (18.7 KB)