Represents the specification of a database platform including its major version and driver used to access it.
Esempio n. 1
0
        protected DbAlterer(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
        {
            if (connectionString == null) throw new ArgumentNullException("connectionString");
            if (dbPlatform == null) throw new ArgumentNullException("dbPlatform");
            if (connectionString == null) throw new ArgumentNullException("connectionString");

            Configuration = CreateRuntimeConfiguration(connectionString, dbPlatform, options);
        }
Esempio n. 2
0
        private RuntimeConfiguration CreateRuntimeConfiguration(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
        {
            var providerLocator = new ProviderLocator(new ProviderFactory()); // CLEAN: use DI container

            var providerInfo = providerLocator.GetLatest(dbPlatform);
            var validatorFactory = new ValidatorFactory(providerInfo, options, providerLocator);
            var validator = validatorFactory.Create();
            var connectionInfo = new ConnectionInfo(connectionString, providerInfo.Metadata.InvariantName, providerInfo.Metadata.SupportsTransactions, providerInfo.Metadata.EnableAnsiQuotesCommand);
            var sqlDispatcher = new SqlDispatcher(options.GetScriptingOptions(), providerInfo.Provider, providerInfo.Metadata);
            return new RuntimeConfiguration(providerInfo, connectionInfo, validator, sqlDispatcher);
        }
Esempio n. 3
0
        protected DbAlterer(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (dbPlatform == null)
            {
                throw new ArgumentNullException("dbPlatform");
            }
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }

            Configuration = CreateRuntimeConfiguration(connectionString, dbPlatform, options);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of <see cref="Migrator"/>.
        /// </summary>
        /// <param name="connectionString">Connection string to the database to be migrated.</param>
        /// <param name="dbPlatform"></param>
        /// <param name="options">Options.</param>
        public Migrator(string connectionString, DbPlatform dbPlatform, MigrationOptions options)
            : base(connectionString, dbPlatform, options)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (dbPlatform == null)
            {
                throw new ArgumentNullException("dbPlatform");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _options = options;
        }
Esempio n. 5
0
        internal bool IsWarningSuppressed(DbPlatform dbPlatform, DbType type, int?size, int?scale)
        {
            foreach (Suppression suppression in _warningSuppressions
                     .Where(s => s.DbPlatform.Matches(dbPlatform) && s.Type == type))
            {
                switch (suppression.Condition)
                {
                case SuppressCondition.WhenSpecifiedWithoutSize:
                    if (!size.HasValue)
                    {
                        return(true);
                    }
                    break;

                case SuppressCondition.WhenSpecifiedWithSize:
                    if (size.HasValue && !scale.HasValue)
                    {
                        return(true);
                    }
                    break;

                case SuppressCondition.WhenSpecifiedWithSizeAndScale:
                    if (size.HasValue && scale.HasValue)
                    {
                        return(true);
                    }
                    break;

                case SuppressCondition.Always:
                    return(true);

                default:
                    continue;
                }
            }
            return(false);
        }
Esempio n. 6
0
 internal bool IsWarningSuppressed(DbPlatform dbPlatform, DbType type, int? size, int? scale)
 {
     foreach (Suppression suppression in _warningSuppressions
         .Where(s => s.DbPlatform.Matches(dbPlatform) && s.Type == type))
     {
         switch (suppression.Condition)
         {
             case SuppressCondition.WhenSpecifiedWithoutSize:
                 if (!size.HasValue) return true;
                 break;
             case SuppressCondition.WhenSpecifiedWithSize:
                 if (size.HasValue && !scale.HasValue) return true;
                 break;
             case SuppressCondition.WhenSpecifiedWithSizeAndScale:
                 if (size.HasValue && scale.HasValue) return true;
                 break;
             case SuppressCondition.Always:
                 return true;
             default:
                 continue;
         }
     }
     return false;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of <see cref="Migrator"/> with default options.
 /// </summary>
 /// <param name="connectionString">Connection string to the database to be migrated.</param>
 /// <param name="dbPlatform"></param>
 public Migrator(string connectionString, DbPlatform dbPlatform) : // signature used in a Wiki example
     this(connectionString, dbPlatform, new MigrationOptions())
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of <see cref="Migrator"/> for a specific module.
 /// </summary>
 /// <param name="connectionString">Connection string to the database to be migrated.</param>
 /// <param name="dbPlatform"></param>
 /// <param name="moduleName">The name of the module whose migrations should be executed.</param>
 public Migrator(string connectionString, DbPlatform dbPlatform, string moduleName) :
     this(connectionString, dbPlatform, new MigrationOptions(moduleName))
 {
 }
Esempio n. 9
0
 internal bool Matches(DbPlatform dbPlatform)
 {
     return(Platform == dbPlatform.Platform && MajorVersion == dbPlatform.MajorVersion && Driver == dbPlatform.Driver);
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of <see cref="DbSchema"/> with default options.
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="dbPlatform"></param>
 public DbSchema(string connectionString, DbPlatform dbPlatform)
     : this(connectionString, dbPlatform, new DbAltererOptions())
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Suppresses validation warnings for <paramref name="dbPlatform"/> and the data type <paramref name="type"/> under the <paramref name="condition"/>.
 /// </summary>
 public void SuppressWarning(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _warningSuppressions.Add(new Suppression(dbPlatform, type, condition));
 }
Esempio n. 12
0
 internal bool Matches(DbPlatform dbPlatform)
 {
     return Platform == dbPlatform.Platform && MajorVersion == dbPlatform.MajorVersion && Driver == dbPlatform.Driver;
 }
Esempio n. 13
0
        private RuntimeConfiguration CreateRuntimeConfiguration(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
        {
            var providerLocator = new ProviderLocator(new ProviderFactory()); // CLEAN: use DI container

            var providerInfo     = providerLocator.GetLatest(dbPlatform);
            var validatorFactory = new ValidatorFactory(providerInfo, options, providerLocator);
            var validator        = validatorFactory.Create();
            var connectionInfo   = new ConnectionInfo(connectionString, providerInfo.Metadata.InvariantName, providerInfo.Metadata.SupportsTransactions, providerInfo.Metadata.EnableAnsiQuotesCommand);
            var sqlDispatcher    = new SqlDispatcher(options.GetScriptingOptions(), providerInfo.Provider, providerInfo.Metadata);

            return(new RuntimeConfiguration(providerInfo, connectionInfo, validator, sqlDispatcher));
        }
Esempio n. 14
0
 /// <summary>
 /// Suppresses validation warnings for <paramref name="dbPlatform"/> and the data type <paramref name="type"/> under the <paramref name="condition"/>.
 /// </summary>
 public void SuppressWarning(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _warningSuppressions.Add(new Suppression(dbPlatform, type, condition));
 }
Esempio n. 15
0
 public Suppression(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _dbPlatform = dbPlatform;
     _type       = type;
     _condition  = condition;
 }
Esempio n. 16
0
 public Suppression(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _dbPlatform = dbPlatform;
     _type = type;
     _condition = condition;
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of <see cref="DbSchema"/>.
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="dbPlatform"></param>
 /// <param name="options"></param>
 public DbSchema(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
     : base(connectionString, dbPlatform, options)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of <see cref="DbSchema"/> with default options.
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="dbPlatform"></param>
 public DbSchema(string connectionString, DbPlatform dbPlatform)
     : this(connectionString, dbPlatform, new DbAltererOptions())
 {
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of <see cref="DbSchema"/>.
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="dbPlatform"></param>
 /// <param name="options"></param>
 public DbSchema(string connectionString, DbPlatform dbPlatform, DbAltererOptions options)
     : base(connectionString, dbPlatform, options)
 {
 }