Need to a extract unique values in a column in datatable
I have datatable with company name, To address, cc address, Loan Numbers and so on
I need get unique values under company name column with corresponding values of to address and cc address
I used this query
dt.AsEnumerable.groupby(function(s) s(“CompanyName”).tostring).select(function(x) x.first()).copyToDatatable()
But this is returning unique values from companyName columns with all the rest columns but i need only three columns company name, To address and cc address
If your goal is to get unique rows based on certain properties, DistinctBy is the right choice. If you want to group your rows by some criteria and possibly perform further operations on each group, then GroupBy is more appropriate.
Solutions:
If you need Unique values applies to all the 3 columns then,
Use Below mentioned LinQ: