コード例 #1
0
 public MySQLHistoryRepository(
     IDatabaseCreator databaseCreator,
     IRawSqlCommandBuilder sqlCommandBuilder,
     MySQLServerConnection connection,
     IDbContextOptions options,
     IMigrationsModelDiffer modelDiffer,
     MySQLMigrationsSqlGenerator sqlGenerator,
     IRelationalAnnotationProvider annotations,
     ISqlGenerationHelper sql)
     : base(
         databaseCreator,
         sqlCommandBuilder,
         connection,
         options,
         modelDiffer,
         sqlGenerator,
         annotations,
         sql)
 {
 }
コード例 #2
0
        private static IHistoryRepository CreateHistoryRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseMySQL(MySQLTestStore.rootConnectionString + "database=test;");
            var connection = new MySQLServerConnection(optionsBuilder.Options, new Logger <MySQLServerConnection>(new LoggerFactory()));

            var typeMapper = new MySQLTypeMapper();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddEntityFrameworkMySQL()
            .AddDbContext <MyTestContext>();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var context = serviceProvider.GetRequiredService <MyTestContext>();

            var creator    = context.GetService <IRelationalDatabaseCreator>();
            var cmdBuilder = context.GetService <IRawSqlCommandBuilder>();

            var options = new DbContextOptions <DbContext>(
                new Dictionary <Type, IDbContextOptionsExtension>
            {
                {
                    typeof(MySQLOptionsExtension),
                    new MySQLOptionsExtension()
                }
            });

            var modelDiffer = new MigrationsModelDiffer(
                new MySQLTypeMapper(),
                new MySQLMigrationsAnnotationProvider(
                    new MigrationsAnnotationProviderDependencies()));

            var logger = new DiagnosticsLogger <DbLoggerCategory.Database.Command>(
                new LoggerFactory(),
                new LoggingOptions(),
                new DiagnosticListener("Fake"));

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                logger,
                typeMapper);

            var sqlGeneratorHelper = new MySQLSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());

            var migrationsSqlGeneratorDependencies = new MigrationsSqlGeneratorDependencies(
                commandBuilderFactory,
                sqlGeneratorHelper,
                typeMapper);

            var migrationsSqlGeneratior = new MySQLMigrationsSqlGenerator(migrationsSqlGeneratorDependencies);

            HistoryRepositoryDependencies dependencies = new HistoryRepositoryDependencies(
                creator,
                cmdBuilder,
                connection,
                options,
                modelDiffer,
                migrationsSqlGeneratior,
                sqlGeneratorHelper);

            return(new MySQLHistoryRepository(dependencies));
        }