Is there an efficient way to get all the duplicate rows from the Datatable and then delete them without using for each?

Hi,

Can you try the following expression?

dtB=dtA.AsEnumerable.GroupBy(Function(r) r("value1").ToString).Where(Function(g) g.Count=1).SelectMany(Function(g) g).CopyToDataTable()

dtC=dtA.AsEnumerable.GroupBy(Function(r) r("value1").ToString).Where(Function(g) g.Count>1).SelectMany(Function(g) g).CopyToDataTable()

Regards,

2 Likes