📜  nhibernate:分页大记录 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:59.347000             🧑  作者: Mango

代码示例1
public IList GetPagedData(int page, int pageSize, out long count)
        {
            try
            {
                var all = new List();

                ISession s = NHibernateHttpModule.CurrentSession;
                IList results = s.CreateMultiCriteria()
                                    .Add(s.CreateCriteria(typeof(Customer)).SetFirstResult(page * pageSize).SetMaxResults(pageSize))
                                    .Add(s.CreateCriteria(typeof(Customer)).SetProjection(Projections.RowCountInt64()))
                                    .List();

                foreach (var o in (IList)results[0])
                    all.Add((Customer)o);

                count = (long)((IList)results[1])[0];
                return all;
            }
            catch (Exception ex) { throw new Exception("GetPagedData Customer da hata", ex); }
      }