I’m listing articles from Article model.
To get all of them I naturally use
var articles = db.Articles;
To get only last one:
var lastArticle = db.Articles.Last();
But now should I get, let’s say, last four?
Article model:
ID
Name
DateCreated
Image
Content
You can order in reverse and get the first N elements:
If you want the result in ascending order, you can append
.OrderBy(a => a.DateCreated).