I have a DataTable with a Name column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the
DataTable
Name
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 );