Hi @Mansour_Dalir ,
You need to pass the "Key" and "Values" values as separate parameters to the LoadDataRow method to ensure that they match the column structure of the DataTable.
Dim q = From row In MyDataTable.AsEnumerable()
Group row.Field(Of String)("Values") By key = row.Field(Of String)("Key") Into Group
Select New With {.Key = key, .Values = String.Join(",", Group)}
Dim distinctTable As DataTable = New DataTable()
distinctTable.Columns.Add("Key", GetType(String))
distinctTable.Columns.Add("Values", GetType(String))
Dim distinctRows = q.Select(Function(item) distinctTable.LoadDataRow(New Object() {item.Key, item.Values}, False))
Dim dt As DataTable = distinctRows.CopyToDataTable()
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.