CopyToDataTable is not a member of System.Data.Datatable

Lets do it one by one

dt_ExtractedData.DefaultView.ToTable(True, Description, Amount) 

will conflict with the syntax as an array with the colnames is needed. It already returns a datatable and thats why copytodatatable is causing the issue. But it will return only the two columns, configured in the colname array

here you can use the LINQ provided by @kumar.varun2 or following variation

(from d in dt_ExtractedData.AsEnumerable
Group d by k1=d(“Description”).toString.Trim, k2=d(“Amount”).toString.Trim into grp=Group
Select r=grp.First()).CopyToDataTable

it will distinct the group members by taking the first group member.

For other scenarios e.g. fetch all unique groups we would filter with where grp.Count = 1

Ensure following:

1 Like