public Int32 SelectCount(SelectBuilder sb, params String[] tableNames) { CheckBeforeUseDatabase(); var cacheKey = ""; var rs = 0; if (EnableCache) { cacheKey = sb + "_SelectCount" + "_" + ConnName; if (XCache.TryGetItem(cacheKey, out rs)) { return(rs); } } Interlocked.Increment(ref _QueryTimes); rs = (Int32)Session.QueryCount(sb); if (EnableCache) { XCache.Add(cacheKey, rs, tableNames); } return(rs); }
public DataSet Select(DbCommand cmd, String[] tableNames) { CheckBeforeUseDatabase(); var cacheKey = ""; DataSet ds = null; if (EnableCache) { cacheKey = cmd.CommandText + "_" + ConnName; if (XCache.TryGetItem(cacheKey, out ds)) { return(ds); } } Interlocked.Increment(ref _QueryTimes); ds = Session.Query(cmd); if (EnableCache) { XCache.Add(cacheKey, ds, tableNames); } return(ds); }
public DataSet Select(String sql, params String[] tableNames) { CheckBeforeUseDatabase(); var cacheKey = sql + "_" + ConnName; DataSet ds = null; if (EnableCache && XCache.TryGetItem(cacheKey, out ds)) { return(ds); } Interlocked.Increment(ref _QueryTimes); ds = Session.Query(sql); if (EnableCache) { XCache.Add(cacheKey, ds, tableNames); } return(ds); }
public Int32 SelectCount(String sql, params String[] tableNames) { CheckBeforeUseDatabase(); String cacheKey = sql + "_SelectCount" + "_" + ConnName; Int32 rs = 0; if (EnableCache && XCache.TryGetItem(cacheKey, out rs)) { return(rs); } Interlocked.Increment(ref _QueryTimes); // 为了向前兼容,这里转为Int32,如果需要获取Int64,可直接调用Session rs = (Int32)Session.QueryCount(sql); if (EnableCache) { XCache.Add(cacheKey, rs, tableNames); } return(rs); }