zoukankan      html  css  js  c++  java
  • NHibernate分页实现条件可变

            /// <summary>
            
    /// NHibernate分页实现---条件可变
            
    /// </summary>
            
    /// <param name="maxResults">记录数</param>
            
    /// <param name="pageStart">开始页</param>
            
    /// <param name="totalRecordCount">总记录数</param>
            
    /// <param name="order">排序方式</param>
            
    /// <param name="criterionList">查询条件</param>
            
    /// <returns></returns>
            public IList<T> GetByCriteria(int maxResults, int pageStart, out int totalRecordCount, Order order, params ICriterion[] criterionList)
            {
                ICriteria criteria 
    = CreateCriteria();
                
    foreach (ICriterion criterion in criterionList)
                    criteria.Add(criterion);

                
    //获取记录总数
                ICriteria criteriaRecordCount = CriteriaTransformer.Clone(criteria);
                totalRecordCount 
    = criteriaRecordCount.SetProjection(NHibernate.Criterion.Projections.RowCount())
                    .UniqueResult
    <int>();


                criteria.SetMaxResults(maxResults);
                criteria.SetFirstResult(pageStart 
    * maxResults);

                
    if (order != null)
                    criteria.AddOrder(order);

                
    return criteria.List<T>();
            }
  • 相关阅读:
    Java-WebDriver模块
    Java-数据类型(八中基本数据类型)
    Java基础
    Java介绍
    Eclipse介绍
    Jmeter-服务器监控技术
    性能测试
    Jmeter-相关字段含义
    Jmeter-监听器
    Jmeter-BeanShell组件应用
  • 原文地址:https://www.cnblogs.com/jes_shaw/p/2007075.html
Copyright © 2011-2022 走看看