public void Init(string connectionString, DatabaseProvider databaseType) { DatabaseProvider = databaseType; conn = DatabaseProvider.GetAndConfigureConnection(connectionString, (connection, dbType) => { switch (dbType) { case DatabaseProvider.MySqlData: MySqlBootstrap.Initialize(); break; case DatabaseProvider.Npgsql: PostgreSqlBootstrap.Initialize(); break; case DatabaseProvider.SystemData: { var dbSetting = new SqlServerDbSetting(); DbSettingMapper.Add(typeof(System.Data.SqlClient.SqlConnection), dbSetting, true); // Map the DbHelper var dbHelper = new SqlServerDbHelper(); DbHelperMapper.Add(typeof(System.Data.SqlClient.SqlConnection), dbHelper, true); // Map the Statement Builder var statementBuilder = new SqlServerStatementBuilder(dbSetting); StatementBuilderMapper.Add(typeof(System.Data.SqlClient.SqlConnection), statementBuilder, true); break; } case DatabaseProvider.MicrosoftData: { var dbSetting = new SqlServerDbSetting(); DbSettingMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), dbSetting, true); // Map the DbHelper var dbHelper = new SqlServerDbHelper(); DbHelperMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), dbHelper, true); // Map the Statement Builder var statementBuilder = new SqlServerStatementBuilder(dbSetting); StatementBuilderMapper.Add(typeof(Microsoft.Data.SqlClient.SqlConnection), statementBuilder, true); break; } case DatabaseProvider.MySqlConnector: MySqlConnectorBootstrap.Initialize(); break; default: throw new ArgumentOutOfRangeException(); } connection.Open(); return(connection); }); }
public static void Initialize() { // Get the connection string var connectionStringForSys = Environment.GetEnvironmentVariable("REPODB_CONSTR_SYS", EnvironmentVariableTarget.Process); var connectionString = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process); // Set the connection string ConnectionStringForSys = (connectionStringForSys ?? @"Server=localhost;Database=sys;Uid=user;Pwd=Password123;"); ConnectionString = (connectionString ?? @"Server=localhost;Database=RepoDb;Uid=user;Pwd=Password123;"); // Initialize MySql MySqlConnectorBootstrap.Initialize(); // Create databases CreateDatabase(); // Create tables CreateTables(); }
public void Initialize() { MySqlConnectorBootstrap.Initialize(); }
public static IServiceCollection AddRepoDb(this IServiceCollection services) { MySqlConnectorBootstrap.Initialize(); return(services); }