示例#1
0
        /// <summary>
        /// 执行SQL查询,返回分页记录集
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="startRowIndex">开始行,0开始</param>
        /// <param name="maximumRows">最大返回行数</param>
        /// <param name="keyColumn">唯一键。用于not in分页</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public DataSet Select(String sql, Int32 startRowIndex, Int32 maximumRows, String keyColumn, String[] tableNames)
        {
            String cacheKey = sql + "_" + startRowIndex + "_" + maximumRows + "_" + ConnName;

            if (EnableCache && XCache.Contain(cacheKey))
            {
                return(XCache.Item(cacheKey));
            }
            DataSet ds = DB.Query(PageSplit(sql, startRowIndex, maximumRows, keyColumn));

            if (EnableCache)
            {
                XCache.Add(cacheKey, ds, tableNames);
            }
            return(ds);
        }
示例#2
0
        /// <summary>
        /// 执行SQL查询,返回总记录数
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public Int32 SelectCount(String sql, String[] tableNames)
        {
            String cacheKey = sql + "_SelectCount" + "_" + ConnName;

            if (EnableCache && XCache.IntContain(cacheKey))
            {
                return(XCache.IntItem(cacheKey));
            }
            Int32 rs = DB.QueryCount(sql);

            if (EnableCache)
            {
                XCache.Add(cacheKey, rs, tableNames);
            }
            return(rs);
        }
示例#3
0
        /// <summary>
        /// 执行SQL查询,返回记录集
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public DataSet Select(String sql, String[] tableNames)
        {
            String cacheKey = sql + "_" + ConnName;

            if (EnableCache && XCache.Contain(cacheKey))
            {
                return(XCache.Item(cacheKey));
            }
            DataSet ds = DB.Query(sql);

            if (EnableCache)
            {
                XCache.Add(cacheKey, ds, tableNames);
            }
            return(ds);
        }
示例#4
0
        /// <summary>
        /// 执行CMD,返回记录集
        /// </summary>
        /// <param name="cmd">CMD</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public DataSet Select(DbCommand cmd, String[] tableNames)
        {
            String cacheKey = cmd.CommandText + "_" + ConnName;

            if (EnableCache && XCache.Contain(cacheKey))
            {
                return(XCache.Item(cacheKey));
            }
            DataSet ds = DB.Query(cmd);

            if (EnableCache)
            {
                XCache.Add(cacheKey, ds, tableNames);
            }
            DB.AutoClose();
            return(ds);
        }