简体   繁体   中英

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();

只需添加descending

orderby title descending

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM