Sofic
Sofic

Reputation: 57

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

Upvotes: 1

Views: 860

Answers (1)

Keith Nicholas
Keith Nicholas

Reputation: 44298

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

Upvotes: 3

Related Questions