Advertisement
Guest User

HomeController

a guest
Jul 23rd, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using MVCBlog.Models;
  8.  
  9. namespace MVCBlog.Controllers
  10. {
  11.     public class HomeController : Controller
  12.     {
  13.         private ApplicationDbContext db = new ApplicationDbContext();
  14.  
  15.  
  16.         //Get: Posts
  17.         public ActionResult Index()
  18.         {
  19.             var posts = db.Posts.Include(p => p.Author).OrderByDescending(p => p.Date).Take(5);
  20.             return View(posts.ToList());
  21.         }
  22.  
  23.        
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement