Remove rows with values duplicated LINQ

Hello,

I would need to know if someone can help me with a linq issue.

I have a datatable in which if values from column A are duplicated, and also values from column B, remove all rows duplicated (if it was duplicated no row can stay on table), or write something in a new column that says something like: duplicated, so I can tell the robot not to process duplicated.

Thanks :slight_smile:

Hey!

Try like this:

Dt.DefaultView.ToTable(True)

This will remove the duplicates in entire table…

If we wants to remove the duplicates in particular column we can do like this…

Dt.Defaultview.ToTable(True,"Column1","Column2")

Regards,
NaNi

Thanks for the reply! But what I need is this:

Input:
image

Output:

image

The rows that contain data duplicated in “TEST” and “A” column should not appear in the output :slight_smile:

try this!!

(From d In dt.AsEnumerable
Group d By k1=d(“TEST”).toString.trim, k2=d(“A”).toString.trim
Into grp = Group
Where grp.Count = 1
Select grp.First).CopyToDataTable

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