I’m trying to return a set of distinct values from a DataTable using LINQ.
This is my code without the ‘Distinct’ part as I’m struggling to formulate the proper linq statement:
DataTable gridData = RgClientData.DataSource as DataTable;
var results = from myRow in gridData .AsEnumerable()
select (myRow.Field<string>("AssignedUser"));
Just adding “Distinct()” to the end of the select does not work. I’m wrestling with the syntax because I don’t fully understand how the ‘Distinct’ part relates to the Linq query.
Could someone point me in the right direction…thanks
Your query needs to be enclosed within parentheses in order to add
Distinctto the end of it:Or you could switch to the fluent syntax: