public static IServiceCollection AddMySQL(this IServiceCollection services, IConfiguration configuration)
        {
            MySQLOptions options = new MySQLOptions();

            configuration.Bind(options);

            AddMySQLInternal(services, options);

            return(services);
        }
        public static IServiceCollection AddMySQL(this IServiceCollection services, Action <MySQLOptions> databaseEngineOptionsSetup)
        {
            MySQLOptions options = new MySQLOptions();

            databaseEngineOptionsSetup(options);

            AddMySQLInternal(services, options);

            return(services);
        }
Esempio n. 3
0
        private IDatabase GetDatabase()
        {
            MySQLOptions mySQLOptions = new MySQLOptions();

            mySQLOptions.DatabaseSettings.Version = 1;
            mySQLOptions.Schemas.Add(new SchemaInfo {
                SchemaName       = "test_db",
                IsMaster         = true,
                ConnectionString = "server=127.0.0.1;port=3306;user=admin;password=_admin;database=test_db;SslMode=None"
            });

            IDatabase database = new DatabaseBuilder(new MySQLBuilder(mySQLOptions).Build()).Build();

            database.Initialize();

            return(database);
        }
        private static void AddMySQLInternal(IServiceCollection services, MySQLOptions options)
        {
            IDatabase database = new DatabaseBuilder(new MySQLBuilder(options).Build()).Build();

            services.AddSingleton(database);
        }