Represents the specification of a database platform including its major version and driver used to access it.
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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;
        }
Example #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);
        }
Example #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;
 }
Example #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())
 {
 }
Example #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))
 {
 }
Example #9
0
 internal bool Matches(DbPlatform dbPlatform)
 {
     return(Platform == dbPlatform.Platform && MajorVersion == dbPlatform.MajorVersion && Driver == dbPlatform.Driver);
 }
Example #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())
 {
 }
Example #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));
 }
Example #12
0
 internal bool Matches(DbPlatform dbPlatform)
 {
     return Platform == dbPlatform.Platform && MajorVersion == dbPlatform.MajorVersion && Driver == dbPlatform.Driver;
 }
Example #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));
        }
Example #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));
 }
Example #15
0
 public Suppression(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _dbPlatform = dbPlatform;
     _type       = type;
     _condition  = condition;
 }
Example #16
0
 public Suppression(DbPlatform dbPlatform, DbType type, SuppressCondition condition)
 {
     _dbPlatform = dbPlatform;
     _type = type;
     _condition = condition;
 }
Example #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)
 {
 }
Example #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())
 {
 }
Example #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)
 {
 }