I’ve tried to find a solution on the forum but all solutions are for different scenarios.
My case is the following:
I have a MyDataTable with approximately 18.000 rows. Tried to use For Each Row but checking for duplicates that way last for hours.
I need to check if a particular column(column is Serial_Number) contains duplicates.
If there are duplicates, I need to count how many duplicates exist for Serial_Number column.
One more important thing is that I must not delete found duplicates.
Which method do you guys think is the fastest and most effective for my scenario?
Thanks in advance.
prepare an empty reportDataTable with Build DataTable - dtReport
Col: SerialNo, Count
Assign Activity
left Side: dtReport
Right side:
(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Serial_Number").toString.Trim into grp=Group
Let ra = new Object(){k,grp.Count}
Select r=dtReport.Rows.Add(ra)).CopyToDataTable
Total report
In case we want only duplicated SerialNOs within the reportz we can do:
(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Serial_Number").toString.Trim into grp=Group
Where grp.Count > 1
Let ra = new Object(){k,grp.Count}
Select r=dtReport.Rows.Add(ra)).CopyToDataTable