Exemplo n.º 1
0
        /// <summary>
        /// 获取top的查询字符串
        /// </summary>
        /// <param name="sql">查询字符串</param>
        /// <param name="top">top值</param>
        /// <returns></returns>
        public string GetTopSelectSql(SelectCondition sql, int top)
        {
            PageContent objPage = new PageContent();

            objPage.IsFillTotalRecords = false;
            objPage.StarIndex          = 0;
            objPage.PageSize           = top;
            return(CutPageSqlCreater.GetCutPageSql(sql.GetSelect(), objPage));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询并且返回集合(游标分页)
        /// </summary>
        /// <param name="sql">要查询的SQL语句</param>
        /// <param name="lstParam">参数集合</param>
        /// <param name="objPage">分页对象</param>
        /// <param name="oper">数据库对象</param>
        /// <returns></returns>
        public static IDataReader Query(string sql, ParamList lstParam, PageContent objPage, DataBaseOperate oper)
        {
            objPage.TotalRecords = CutPageSqlCreater.GetTotalRecord(lstParam, oper, sql, objPage.MaxSelectRecords, null);
            //long totalPage = (long)Math.Ceiling((double)objPage.TotalRecords / (double)objPage.PageSize);
            //objPage.TotalPage = totalPage;
            if (objPage.CurrentPage >= objPage.TotalPage - 1)
            {
                objPage.CurrentPage = objPage.TotalPage - 1;
            }
            IDataReader reader = null;

            string qsql = CutPageSqlCreater.GetCutPageSql(sql, objPage);

            reader = oper.Query(qsql, lstParam, null);

            return(reader);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询并且返回DataSet(游标分页)
        /// </summary>
        /// <param name="sql">要查询的SQL语句</param>
        /// <param name="lstParam">参数集合</param>
        /// <param name="objPage">分页对象</param>
        /// <param name="oper">数据库对象</param>
        /// <param name="curType">映射的实体类型(如果用回数据库的原列名,则此为null)</param>
        /// <returns></returns>
        public static DataTable QueryDataTable(string sql, ParamList lstParam, PageContent objPage, DataBaseOperate oper, Type curType)
        {
            objPage.TotalRecords = CutPageSqlCreater.GetTotalRecord(lstParam, oper, sql, objPage.MaxSelectRecords, null);
            long totalPage = (long)Math.Ceiling((double)objPage.TotalRecords / (double)objPage.PageSize);

            objPage.TotalPage = totalPage;
            if (objPage.CurrentPage >= objPage.TotalPage - 1)
            {
                objPage.CurrentPage = objPage.TotalPage - 1;
            }
            if (objPage.CurrentPage >= objPage.TotalPage - 1)
            {
                objPage.CurrentPage = objPage.TotalPage - 1;
            }

            DataTable   ret    = new DataTable();
            IDataReader reader = null;

            try
            {
                string qsql = CutPageSqlCreater.GetCutPageSql(sql, objPage);
                reader = oper.Query(qsql, lstParam, null);

                if (curType == null)
                {
                    ret = CacheReader.GenerateDataTable(reader, "newDt", false);
                }
                else
                {
                    ret = CacheReader.GenerateDataTable(reader, "newDt", curType, false);
                }
            }
            finally
            {
                reader.Close();
                //oper.CloseDataBase();
            }
            return(ret);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 生成分页SQL语句
 /// </summary>
 /// <param name="list">参数列表</param>
 /// <param name="oper">连接对象</param>
 /// <param name="objCondition">条件对象</param>
 /// <param name="objPage">分页记录类</param>
 /// <returns></returns>
 public string CreatePageSql(ParamList list, DataBaseOperate oper, SelectCondition objCondition,
                             PageContent objPage, bool useCache)
 {
     return(CutPageSqlCreater.CreatePageSql(list, oper, objCondition, objPage, useCache));
 }