Example #1
0
        /// <summary>
        /// 分页查询数据
        /// </summary>
        /// <param name="statementName">查询SQL的ID(不包含namespace)</param>
        /// <param name="pageRequest">PageRequest.getFilters()查询参数和条件数据</param>
        /// <param name="statementNameCount">查询总数SQL的ID(不包含namespace)</param>
        /// <param name="pageRequestCount">PageRequest.getFilters()查询参数和条件数据</param>
        /// <returns>Page&lt;Object&gt;</returns>
        protected Page <Object> QueryPage(String statementName, PageRequest pageRequest, String statementNameCount, PageRequest pageRequestCount)
        {
            int           totalCount = QueryCount(statementNameCount, pageRequestCount);
            Page <Object> page       = new Page <Object>(pageRequest.CurrentPage, pageRequest.PageSize, totalCount);
            IList         list;

            if (dialect != null && dialect.SupportsLimitOffset())
            {
                list = OffsetLimitInterceptor.QueryPageList(dialect, session, GetStatementName(statementName), pageRequest.Filters, page.FirstResultIndex, page.PageSize);
            }
            else
            {
                Console.WriteLine("请注意,你正在使用逻辑分页!");
                list = session.QueryForList(GetStatementName(statementName), pageRequest.Filters, page.FirstResultIndex, page.PageSize);
            }
            page.SetResult(list);
            return(page);
        }