Use the following code to remove duplicate names based on column names.
[Inputs : coll,collName ]
[Output: groups ]
Dim hTable As New Hashtable()
Dim duplicateList As New ArrayList()
'Add list of all the unique item value to hashtable, which stores combination of key, value pair.
'And add duplicate item value in arraylist.
For Each drow_1 As DataRow In coll.Rows
If hTable.Contains(drow_1(colName)) Then
duplicateList.Add(drow_1)
Else
hTable.Add(drow_1(colName), String.Empty)
End If
Next
'Removing a list of duplicate items from datatable.
For Each dRow_2 As DataRow In duplicateList
coll.Rows.Remove(dRow_2)
Next
groups = coll
------------------------------
Jane Jebarson Senior Automation Engineer
Engineer
Allianz
Europe/London
------------------------------
Original Message:
Sent: 10-14-2020 11:23
From: Guggs Kia
Subject: Remove duplicates from collection based on specific column
Hello Community,
I have a collection, suppose Col1. It has 2 columns i.e. Operating System and UserId.
I need to filter out the rows in Col1 with its name as Linux and Mac. But before it filters both I want to remove duplicates if any.
Operating System UserId
Mac. 123
Mac. 123
Linux. 652
Mac. 124
First thing, two seperate collections for Linux and Mac.
Second thing, removing duplicates based on UserId.
Note:one userId can have multiple OS.
------------------------------
Guggs Kia
------------------------------