How do I get a distinct, ordered list of names from a DataTable using LINQ?

The problem is that the Distinct
operator does not grant that it will
maintain the original order of
values.

So your query will need to work like this

var names = (from DataRow dr in dataTable.Rows
             select (string)dr["Name"]).Distinct().OrderBy( name => name );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)