Exemplo n.º 1
0
        /// <summary>
        /// Returns database name for provided connection.
        /// Returns UNUSED_DB if fully-qualified table name doesn't support database name.
        /// </summary>
        public static string GetDatabaseName(IDataContext db)
        {
            switch (TestProvName.GetFamily(GetContextName(db)))
            {
            case ProviderName.SQLiteClassic:
            case TestProvName.SQLiteClassicMiniProfilerMapped:
            case TestProvName.SQLiteClassicMiniProfilerUnmapped:
            case ProviderName.SQLiteMS:
                return("main");

            case ProviderName.Access:
            case ProviderName.AccessOdbc:
                return("Database\\TestData");

            case ProviderName.MySql:
            case ProviderName.MySqlConnector:
            case TestProvName.MariaDB:
            case TestProvName.MySql55:
            case ProviderName.PostgreSQL:
            case ProviderName.PostgreSQL92:
            case ProviderName.PostgreSQL93:
            case ProviderName.PostgreSQL95:
            case TestProvName.PostgreSQL10:
            case TestProvName.PostgreSQL11:
            case ProviderName.DB2:
            case ProviderName.Sybase:
            case ProviderName.SybaseManaged:
            case ProviderName.SqlServer2000:
            case ProviderName.SqlServer2005:
            case ProviderName.SqlServer2008:
            case ProviderName.SqlServer2012:
            case ProviderName.SqlServer2014:
            case ProviderName.SqlServer2017:
            case TestProvName.SqlAzure:
                return(db.GetTable <LinqDataTypes>().Select(_ => DbName()).First());

            case ProviderName.Informix:
            case ProviderName.InformixDB2:
                return(db.GetTable <LinqDataTypes>().Select(_ => DbInfo("dbname")).First());
            }

            return(NO_DATABASE_NAME);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns schema name for provided connection.
        /// Returns UNUSED_SCHEMA if fully-qualified table name doesn't support database name.
        /// </summary>
        public static string GetSchemaName(IDataContext db)
        {
            switch (TestProvName.GetFamily(GetContextName(db)))
            {
            case ProviderName.Informix:
            case ProviderName.InformixDB2:
            case ProviderName.Oracle:
            case ProviderName.OracleNative:
            case ProviderName.OracleManaged:
            case TestProvName.Oracle11Native:
            case TestProvName.Oracle11Managed:
            case ProviderName.PostgreSQL:
            case ProviderName.PostgreSQL92:
            case ProviderName.PostgreSQL93:
            case ProviderName.PostgreSQL95:
            case TestProvName.PostgreSQL10:
            case TestProvName.PostgreSQL11:
            case ProviderName.DB2:
            case ProviderName.Sybase:
            case ProviderName.SybaseManaged:
            case ProviderName.SqlServer2005:
            case ProviderName.SqlServer2008:
            case ProviderName.SqlServer2012:
            case ProviderName.SqlServer2014:
            case ProviderName.SqlServer2017:
            case TestProvName.SqlAzure:
            case ProviderName.SapHanaNative:
            case ProviderName.SapHanaOdbc:
                return(db.GetTable <LinqDataTypes>().Select(_ => SchemaName()).First());

            case ProviderName.SqlServer2000:
                return(db.FromSql <string>($"SELECT TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = {nameof(LinqDataTypes)}").First());
            }

            return(NO_SCHEMA_NAME);
        }