示例#1
0
        /// <summary>
        /// 标准的记录查询函数
        /// </summary>
        /// <param name="where"></param>
        /// <param name="pagerInfo"></param>
        /// <returns></returns>
        private DataTable FindToDataTable(string where, PagerInfo pagerInfo)
        {
            PagerHelper helper   = new PagerHelper("All_Customer", "*", "LastUpdated", pagerInfo.PageSize, pagerInfo.CurrenetPageIndex, true, where);
            string      countSql = helper.GetPagingSql(DatabaseType.Access, true);
            string      dataSql  = helper.GetPagingSql(DatabaseType.Access, false);

            string value = SqlValueList(countSql);

            pagerInfo.RecordCount = Convert.ToInt32(value);//为了显示具体的信息,需要设置总记录数
            DataTable dt = SqlTable(dataSql);

            return(dt);
        }
示例#2
0
        /// <summary>
        /// 根据条件查询数据库,并返回DataTable集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定DataTable的集合</returns>
        public override DataTable FindToDataTable(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.MySql, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string dataSql = helper.GetPagingSql(DatabaseType.MySql, false);

            return(GetDataTableBySql(dataSql, trans));
        }
示例#3
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定对象的集合</returns>
        public override List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            PagerHelper helper = new PagerHelper(tableName, this.SelectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(true, DatabaseType.PostgreSQL);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string   dataSql = helper.GetPagingSql(false, DatabaseType.PostgreSQL);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }
示例#4
0
        public virtual List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }
            PagerHelper helper   = new PagerHelper(tableName, this.selectedFields, fieldToSort, info.PageSize, info.CurrentPageIndex, desc, condition);
            string      countSql = helper.GetPagingSql(true);
            string      strCount = SqlValueList(countSql);

            info.RecordCount = Convert.ToInt32(strCount);
            string   dataSql = helper.GetPagingSql(false);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }
示例#5
0
        /// <summary>
        /// 根据条件查询数据库,并返回DataTable集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定DataTable的集合</returns>
        public override DataTable FindToDataTable(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrentPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.SqlServer, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string dataSql = helper.GetPagingSql(DatabaseType.SqlServer, false);

            return(GetDataTableBySql(dataSql, trans));
        }
示例#6
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定对象的集合</returns>
        public override List <T> FindWithPager(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_ERR, string.Format("检测出SQL注入的恶意数据, {0}", condition), typeof(BaseDALSQLite <T>));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.SQLite, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string   dataSql = helper.GetPagingSql(DatabaseType.SQLite, false);
            List <T> list    = GetList(dataSql, null, trans);

            return(list);
        }