Suge
Suge

Reputation: 39

Sort in descending order using LINQ query syntax

My LINQ sort is working fine (string & date) for asc... I'd like to get it working for desc. How can I reverse this? I'm going to be using viewstate to maintain the current sort direction.

 IEnumerable<DataRow> orderedRows;
 orderedRows = from row in dtValues.AsEnumerable() 
 let title = Convert.ToString(row.Field<string>("TITLE"), CultureInfo.InvariantCulture)
             orderby title
               select row;
 dValues = orderedRows.CopyToDataTable();

Upvotes: 0

Views: 370

Answers (1)

Habib
Habib

Reputation: 223247

Just add descending

orderby title descending

Upvotes: 6

Related Questions