Example #1
0
        private MimerConnectionStringBuilder AddConnectionStringOptions(MimerConnectionStringBuilder builder)
        {
            var boolHandling = _mySqlOptionsExtension.DefaultDataTypeMappings?.ClrBoolean;

            switch (boolHandling)
            {
            case null:
                // Just keep using whatever is already defined in the connection string.
                break;

            case MySqlBooleanType.Default:
            //case MySqlBooleanType.TinyInt1:
            //    builder.TreatTinyAsBoolean = true;
            //    break;

            case MySqlBooleanType.None:
            //case MySqlBooleanType.Bit1:
            //    builder.TreatTinyAsBoolean = false;
            //    break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(builder);
        }
Example #2
0
        public virtual IMySqlRelationalConnection CreateMasterConnection()
        {
            var relationalOptions = RelationalOptionsExtension.Extract(Dependencies.ContextOptions);
            var connection        = (MimerConnection)relationalOptions.Connection;
            var connectionString  = connection?.ConnectionString ?? relationalOptions.ConnectionString;

            // Add master connection specific options.
            var csb = new MimerConnectionStringBuilder(connectionString)
            {
                Database = string.Empty,
                Protocol = "tcp"
                           //Pooling = false
            };

            csb = AddConnectionStringOptions(csb);

            // Apply modified connection string.
            relationalOptions = relationalOptions.WithConnectionString(csb.ConnectionString);

            var optionsBuilder = new DbContextOptionsBuilder();
            var optionsBuilderInfrastructure = (IDbContextOptionsBuilderInfrastructure)optionsBuilder;

            optionsBuilderInfrastructure.AddOrUpdateExtension(relationalOptions);

            return(new MySqlRelationalConnection(Dependencies.With(optionsBuilder.Options))
            {
                IsMasterConnection = true
            });
        }
        public MimerConnectionSettings(string connectionString)
        {
            var csb = new MimerConnectionStringBuilder(connectionString);

            //if (csb.GuidFormat == MySqlGuidFormat.Default)
            //{
            //    GuidFormat = csb.OldGuids
            //        ? MySqlGuidFormat.LittleEndianBinary16
            //        : MySqlGuidFormat.Char36;
            //}
            //else
            //{
            //    GuidFormat = csb.GuidFormat;
            //}

            //TreatTinyAsBoolean = csb.TreatTinyAsBoolean;
        }
        public static DbContextOptionsBuilder UseMySql(
            [NotNull] this DbContextOptionsBuilder optionsBuilder,
            [NotNull] DbConnection connection,
            [CanBeNull] Action <MySqlDbContextOptionsBuilder> mySqlOptionsAction = null)
        {
            Check.NotNull(optionsBuilder, nameof(optionsBuilder));
            Check.NotNull(connection, nameof(connection));

            var csb = new MimerConnectionStringBuilder(connection.ConnectionString);

            var extension = GetOrCreateExtension(optionsBuilder).WithConnection(connection);

            ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);
            ConfigureWarnings(optionsBuilder);
            mySqlOptionsAction?.Invoke(new MySqlDbContextOptionsBuilder(optionsBuilder));

            return(optionsBuilder);
        }