Hello Mates, I have an issue with identifying duplicates in a table based on the two or three columns and keep the ones which have more than one distinct values in a column of a group.
For say we have a Table as below:
Initial :
Task is to get the Duplicates based on Name and Place Columns.
Now we have the keep the groups which have more that one distinct values in the company column of each group…
Prem Houston combination group belongs to both 123 and 456 companies, we have to keep them.
I am able to get the duplicates by using a linq query
(From d In Table
Group d By C1 =d(“Name”).ToString.Trim, C2=d(“Place”).ToString.Trim Into grp=Group
**Where grp.count > 1 **
Select grp.toList).SelectMany(Function (x) x).CopyToDatatable
I am unable to add another condition counting the uniques values of the group.
(From d In Table
Group d By C1 =d(“Name”).ToString.Trim, C2=d(“Place”).ToString.Trim Into grp=Group
Where grp.count > 1 And grp.Company.Rows.Distinct.count >1
Select grp.toList).SelectMany(Function (x) x).CopyToDatatable
The above does not work… Kindly help me resolve the issue…
Thank you in advance…