Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MVCBlog.Models;
- namespace MVCBlog.Controllers
- {
- public class HomeController : Controller
- {
- private ApplicationDbContext db = new ApplicationDbContext();
- //Get: Posts
- public ActionResult Index()
- {
- var posts = db.Posts.Include(p => p.Author).OrderByDescending(p => p.Date).Take(5);
- return View(posts.ToList());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement