码迷,mamicode.com
首页 > Web开发 > 详细

NHibernate分页

时间:2015-01-10 16:22:42      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

转载:http://www.cnblogs.com/tenghoo/archive/2011/02/14/1954393.html

public IList<Orders> GetUserOrderByUserID(string userid, int PageIndex, int PageSize, out long count)
        {
            using (ISession _session = base.GetSession())
            {
                var hql = "select count(*) from Orders where userid=:userid";
                IQuery query = _session.CreateQuery(hql);
                query.SetString("userid", userid);
                object obj = query.UniqueResult();
                long.TryParse(obj.ToString(), out count);


                var list = from p in _session.Linq<Orders>()
                   .Where(p => p.UserID == userid)
                   .OrderByDescending(p => p.Otime)
                   .Skip((PageIndex - 1) * PageSize)
                   .Take(PageSize)
                           select p;

                return list.ToList<Orders>();
            }
        }

 

NHibernate分页

标签:

原文地址:http://www.cnblogs.com/zfanlong1314/p/4214909.html

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