Exemplo n.º 1
0
        /// <summary>
        /// 执行写操作
        /// </summary>
        public static WriteReturn Write(string name, DbParameter[] param, DataContext db = null, string key = null, bool isOutSql = false)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);
                BaseAop.AopMapBefore(name, sql, param, config, AopType.Map_Write);
                isOutSql = isOutSql ? isOutSql : IsMapLog(name);
                var result = FastWrite.ExecuteSql(sql, param, db, key, isOutSql, false);
                BaseAop.AopMapAfter(name, sql, param, config, AopType.Map_Write, result);
                return(result);
            }
            else
            {
                BaseAop.AopMapBefore(name, "", param, config, AopType.Map_Write);
                var data = new WriteReturn();
                BaseAop.AopMapAfter(name, "", param, config, AopType.Map_Write, data);
                return(data);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 执行写操作
        /// </summary>
        public static WriteReturn Write(string name, DbParameter[] param, DataContext db = null, string key = null)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);

                return(FastWrite.ExecuteSql(sql, param, db, key));
            }
            else
            {
                return(new WriteReturn());
            }
        }