How to remove common rows from data tables

Hi everyone,
I have 2 data tables and I need compare them and remove each of them common rows. I just thought like venn scheme A-(AՈB) . How can I do it?
Any help will be appreciated.

@EMREUYSAL
find starter help here:
DataTable_SetOperations.xaml (8.9 KB)

was done with the set operations Intersect And Except:

Another techniques is to do it with Any and denied Any in combination sequenceEqual
(have also a look here on the use of sequenceequal - [HowTo] - Find Duplicate / NonDuplicate rows - checking all columns - without explicit listing the colnames/index )

to safe it up it is recommended to do the empty result check similar as below

1 Like

Actually 2 data tables have only one column. Already find the common ones using join data tables with join type Inner. ıf I can use except method for data tables or convert them into list. It will be fine probably

@EMREUYSAL
I am not sure if I did understand you in complete:

Actually 2 data tables have only one column

Approach works dynamice with the implementation of the used datarowcomparer
But share some datasamples with us / remove 1 col from demo tables

Already find the common ones using join data tables with join type Inner

yes another technique, saw some rare cases with side effets

ıf I can use except method for data tables or convert them into list. It will be fine probably

Applying Except with the combination of common found by join should work as well (assumed, there are in same structure)

Just do the test it. it is quickly prototyped

kontrol123.xaml (9.0 KB)

I tried but did not work. Could you check?

@EMREUYSAL
just crosscheck my demo xaml. The datarowcomparer is missing in your implementation. Thats the reason why it is failling

e.g like: dtData1.AsEnumerable.Except(dt1Common.AsEnumerable, DataRowComparer.Default).CopyToDataTable

2 Likes

Thank you so much, At first look to your xaml I did not notice

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.