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); }); }
/// <summary> /// Initialize the creation of the database. /// </summary> public static void Initialize() { // Set the connection string ConnectionStringForPosgres = Environment.GetEnvironmentVariable("REPODB_CONSTR_POSTGRESDB", EnvironmentVariableTarget.Process) ?? "Server=127.0.0.1;Port=5432;Database=postgres;User Id=postgres;Password=Password123;"; ConnectionStringForRepoDb = Environment.GetEnvironmentVariable("REPODB_CONSTR", EnvironmentVariableTarget.Process) ?? "Server=127.0.0.1;Port=5432;Database=RepoDb;User Id=postgres;Password=Password123;"; // Initialize PostgreSql PostgreSqlBootstrap.Initialize(); // Create databases CreateDatabase(); // Create tables CreateTables(); }
public void Initialize() { PostgreSqlBootstrap.Initialize(); }
public void Setup() { SqlServerBootstrap.Initialize(); PostgreSqlBootstrap.Initialize(); }
public void Setup() { PostgreSqlBootstrap.Initialize(); TypeMapper.Add(typeof(DateTime), DbType.DateTime2, true); BaseSetup(); }