Nhibernate 分页

时间:2014-09-22 01:21:01   收藏:0   阅读:314
bubuko.com,布布扣
public IList<Student> GetStudentByPage(int pageSize, int pageIndex, string SName)
        {
            ISession session = NHibernateHelper.GetCurrentSession();
            ITransaction trans = session.BeginTransaction();
            //HQL查询
            IList<Student> studentList = new List<Student>();
            //string sql = "from Student";
            //studentList = session.CreateQuery(sql)
            //    .SetFirstResult((pageIndex - 1) * pageSize)
            //    .SetMaxResults(pageSize)
            //    .List<Student>();

            //SQL查询

            //studentList = session.CreateSQLQuery("SELECT * FROM Student")
            //    .SetFirstResult((pageIndex - 1) * pageSize)
            //    .SetMaxResults(pageSize)
            //    .SetResultTransformer(Transformers.AliasToBean<Student>()).List<Student>();
            return studentList;
        }
View Code

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!