码迷,mamicode.com
首页 > 编程语言 > 详细

Entity Framework排序

时间:2015-09-12 22:19:41      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:

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

  

Entity Framework排序

标签:

原文地址:http://www.cnblogs.com/milo-xie/p/4803667.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!