/// <summary> /// Creates a <see cref="DatabaseInfo"/> /// </summary> public static DatabaseInfo CreateDatabaseInfo(SupportedDatabaseType type, string connectionString) { switch (type) { case SupportedDatabaseType.SqlServer: return(new SqlServerInfo(connectionString)); case SupportedDatabaseType.MySql: return(new MySqlInfo(connectionString)); case SupportedDatabaseType.Oracle: return(new OracleInfo(connectionString, false)); } throw new ApplicationException($"{type} is an unknown database type."); }
/// <summary> /// This should only be used for two purposes. First, to create objects that will be returned by the /// mainDataAccessStateGetter argument of /// GlobalInitializationOps.InitStatics. Second, to create supplemental data-access state objects, which you may need if /// you want to communicate with a /// database outside of the main transaction. /// </summary> /// <param name="connectionString"></param> /// <param name="databaseConnectionInitializer"> /// A method that is called whenever a database connection is requested. Can be used to initialize the /// connection. /// </param> /// <param name="databaseType"></param> public DataAccessState(SupportedDatabaseType databaseType, string connectionString, Action <DBConnection> databaseConnectionInitializer = null) { this.databaseType = databaseType; this.connectionString = connectionString; connectionInitializer = databaseConnectionInitializer ?? (connection => { }); }