示例#1
0
 //最大值加一
 public static string maxplus(IDbContext db, string table, string field, ParamQuery pQuery)
 {
     //var where = pQuery.GetData().WhereSql;
     var sqlWhere = " where 1 = 1 ";
     if (pQuery != null)
         sqlWhere += " and " +  pQuery.GetData().WhereSql;
     var dbkey = db.Sql(String.Format("select isnull(max({0}),0) from {1} {2}", field, table, sqlWhere)).QuerySingle<string>();
     var cachedKeys = getCacheKey(table, field);
     var currentKey = maxOfAllKey(cachedKeys, ZConvert.ToString(dbkey));
     var key = ZConvert.ToString(currentKey + 1);
     SetCacheKey(table, field, key);
     return key;
 }
示例#2
0
        protected int queryRowCount(ParamQuery param, dynamic rows)
        {
            if (rows != null)
            {
                if (null == param || param.GetData().PagingItemsPerPage == 0)
                {
                    return(rows.Count);
                }
            }

            var RowCountParam = param;
            var sql           = BuilderParse(RowCountParam.Paging(1, 0).OrderBy(string.Empty)).GetSql();

            return(db.Sql(@"select count(*) from ( " + sql + " ) tb_temp").QuerySingle <int>());
        }
示例#3
0
        public static string inventory(IDbContext db, string table, string field, ParamQuery pQuery)
        {
            //var where = pQuery.GetData().WhereSql;
            var sqlWhere = " where 1 = 1 ";

            if (pQuery != null)
            {
                sqlWhere += " and " + pQuery.GetData().WhereSql;
            }
            var dbkey      = db.Sql(String.Format("select isnull(max({0}),0) from {1} {2}", field, table, sqlWhere)).QuerySingle <string>();
            var cachedKeys = getCacheKey(table, field);
            var currentKey = maxOfAllKey(cachedKeys, ZConvert.ToString(dbkey));
            var key        = ZConvert.ToString(currentKey + 1);

            SetCacheKey(table, field, key);
            return(key);
        }
示例#4
0
        //最大值加一
        public static string maxplus(IDbContext db, string table, string field, ParamQuery pQuery)
        {
            var sqlWhere = " where 1 = 1 ";
 
            if (pQuery != null)
            {
                var conditions = pQuery.GetData().Where;
                conditions.ForEach(c => sqlWhere += c.ToSql( GetDbType(db), !string.IsNullOrWhiteSpace(sqlWhere)));
            }

            var dbkey = db.Sql(String.Format("select {{isnull,max({0}),0}} from {1} {2}", field, table, sqlWhere)).QuerySingle<string>();
            var cachedKeys = getCacheKey(table, field);
            var currentKey = maxOfAllKey(cachedKeys, ConvertHelper.ToString(dbkey));
            var key = ConvertHelper.ToString(currentKey + 1);
            SetCacheKey(table, field, key);
            return key;
        }
示例#5
0
        //最大值加一
        public static string maxplus(IDbContext db, string table, string field, ParamQuery pQuery)
        {
            var sqlWhere = " where 1 = 1 ";

            if (pQuery != null)
            {
                var conditions = pQuery.GetData().Where;
                conditions.ForEach(c => sqlWhere += c.ToSql(GetDbType(db), !string.IsNullOrWhiteSpace(sqlWhere)));
            }

            var dbkey      = db.Sql(String.Format("select {{isnull,max({0}),0}} from {1} {2}", field, table, sqlWhere)).QuerySingle <string>();
            var cachedKeys = getCacheKey(table, field);
            var currentKey = maxOfAllKey(cachedKeys, ConvertHelper.ToString(dbkey));
            var key        = ConvertHelper.ToString(currentKey + 1);

            SetCacheKey(table, field, key);
            return(key);
        }