public ActionResult Index() { using (ApplicationDbContext db = new ApplicationDbContext()) { //var log = db.Log.ToList(); //return View(log); /* order by date asc var log = from p in db.Log orderby p.Date select p; return View(log.ToList()); * */ /* order by date desc var log = from p in db.Log orderby p.Date descending select p; return View(log.ToList()); * */ /* order by date asc var log = db.Log.OrderBy(p => p.Date).ToList(); return View(log); * */ /* order by date desc var log = db.Log.OrderByDescending(p => p.Date).ToList(); return View(log); * */ /* order by date desc,id asc var log = from p in db.Log orderby p.Date descending, p.ID select p; return View(log.ToList()); * */ //order by date desc,id asc var log = db.Log.OrderByDescending(p => p.Date).ThenBy(p => p.ID).ToList(); return View(log); } }
时间: 2024-10-24 14:09:16