Example #1
0
        public bool ExistsTable(string name, bool ignoreCase)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }
            var tbname = _commonUtils.SplitTableName(name);

            if (tbname?.Length == 1)
            {
                var userId = (_orm.Ado.MasterPool as OdbcDamengConnectionPool)?.UserId;
                if (string.IsNullOrEmpty(userId))
                {
                    using (var conn = _orm.Ado.MasterPool.Get())
                    {
                        userId = OdbcDamengConnectionPool.GetUserId(conn.Value.ConnectionString);
                    }
                }
                tbname = new[] { userId, tbname[0] };
            }
            if (ignoreCase)
            {
                tbname = tbname.Select(a => a.ToLower()).ToArray();
            }
            var sql = $" select 1 from all_tab_comments where {(ignoreCase ? "lower(owner)" : "owner")}={_commonUtils.FormatSql("{0}", tbname[0])} and {(ignoreCase ? "lower(table_name)" : "table_name")}={_commonUtils.FormatSql("{0}", tbname[1])}";

            return(string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, sql)) == "1");
        }
        public OdbcDamengConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
        {
            this.UserId = OdbcDamengConnectionPool.GetUserId(connectionString);

            this.availableHandler   = availableHandler;
            this.unavailableHandler = unavailableHandler;
            var policy = new OdbcOracleConnectionPoolPolicy
            {
                _pool = this,
                Name  = name
            };

            this.Policy             = policy;
            policy.ConnectionString = connectionString;
        }