简体   繁体   中英

LINQ query the most recent records

How to modify this query to be able to select the 5 most recent records sorted by title?

IEnumerable<Story> recentStories = 
            (from s in stories 
             orderby s.Date descending 
             select s).Take(5);
IEnumerable<Story> recentStories = 
            (from s in stories 
             orderby s.Date descending 
             select s).Take(5).OrderBy(s => s.Title);

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