How can I implement this? Preferably in LINQ if possible
I have a Driver_DT and it has five columns (UID, Name, Gender, Age, and Sponsor). If a row has a duplicate value of UID, Name, Gender, and Age from other row(s) then it will be added on DuplicateList_DT.
INPUT DATATABLE:
EXPECTED OUTPUT:
As you noticed, 789D Hamilton has a duplicate but they have different age so it will not be added to DuplicateList_DT.
Also, if you noticed 123A Verstappen has duplicates (3 rows in total) but the other one has a different value of Gender and it is NOT added on the DuplicateList_DT while the other duplicate row has a different value of Sponsor but it is added on the DuplicateList_DT
UID and Name and Gender and Age should have same value to other row(s) to be added on DuplicateList_DT.
How can I implement this? Preferably in LINQ if possible
(From d in dtData.AsEnumerable
Let sk = String.Join(“_”,{“UID”,“Name”,“Gender”,“Age”}.Select(Function (x) d(x).toString.Trim))
Group d by k=sk into grp = Group
Where grp.Count > 1
From g in grp
Order by dtData.Rows.IndexOf(g)
Select r=g).CopyToDataTable