コード例 #1
0
        public override string GetTableName(PocoData pd, TableNameManger tn)
        {
            var ti = pd.TableInfo;

            if (ti.TableName.Contains("."))
            {
                return(ti.TableName);
            }
            var tag       = ti.FixTag;
            var tableName = ti.TableName;

            var name = tn.Get(tag);

            if (name != null)
            {
                tableName = name.TablePrefix + tableName + name.TableSuffix;
            }
            var schemaName = ti.SchemaName;

            if (string.IsNullOrEmpty(schemaName))
            {
                return(this.EscapeSqlIdentifier(tableName));
            }
            return(string.Format("[{0}_{1}]", schemaName, tableName));
        }
コード例 #2
0
        internal T Run <T>(string sql, object[] args, Func <T> func, params string[] methodtags)
        {
            if (_usedCacheService == false && _usedCacheServiceOnce == false)
            {
                return(func());
            }
            _usedCacheServiceOnce = false;//记录一次

            StringBuilder sb = new StringBuilder();

            if (_usedCacheServiceOnce)
            {
                sb.Append(_cacheTag);
                sb.Append("|");
            }
            sb.Append(sql);
            sb.Append("|");
            sb.Append(typeof(T).FullName);

            for (int i = 0; i < args.Length; i++)
            {
                sb.Append("|");
                sb.Append(args[i].ToString());
            }
            for (int i = 0; i < methodtags.Length; i++)
            {
                sb.Append("|");
                sb.Append(methodtags[i]);
            }
            var t = _tableNameManger.Get <T>();

            if (t != null)
            {
                sb.Append("|");
                sb.Append(t.ToString());
            }
            string tag = sb.ToString();// getMd5String(sb.ToString());

            if (_usedCacheServiceOnce)
            {
                return(_cacheService.Get(tag, func, _cacheTimeOnce, _cacheTag));
            }
            return(_cacheService.Get(tag, func, _cacheTime, null));
        }
コード例 #3
0
        public virtual string EscapeTableName(PocoData pd, TableNameManger tn)
        {
            var ti    = pd.TableInfo;
            var index = ti.TableName.IndexOf('.');

            if (index > -1)
            {
                return(ti.TableName.Substring(index));
            }
            var tag       = ti.FixTag;
            var tableName = ti.TableName;

            var name = tn.Get(tag);

            if (name != null)
            {
                tableName = name.TablePrefix + tableName + name.TableSuffix;
            }
            return(EscapeSqlIdentifier(tableName));
        }
コード例 #4
0
        public virtual string GetTableName(Table ti, TableNameManger _tableNameManger)
        {
            if (ti.TableName.Contains("."))
            {
                return(ti.TableName);
            }
            var tag       = ti.FixTag;
            var tableName = ti.TableName;

            var name = _tableNameManger.Get(tag);

            if (name != null)
            {
                tableName = name.TablePrefix + tableName + name.TableSuffix;
            }
            var schemaName = ti.SchemaName;

            if (string.IsNullOrEmpty(schemaName))
            {
                return(provider.EscapeSqlIdentifier(tableName));
            }
            return(string.Format("{0}.{1}", provider.EscapeSqlIdentifier(schemaName), provider.EscapeSqlIdentifier(tableName)));
        }