public static DbManager Create(GenTablesOptions options) { SqlConnection connection; try { connection = new SqlConnection(options.ConnectionString); } catch (ArgumentException e) { throw new SqExpressCodeGenException($"MsSQL connection string has incorrect format \"{options.ConnectionString}\"", e); } if (string.IsNullOrEmpty(connection.Database)) { throw new SqExpressCodeGenException("MsSQL connection string has to contain \"database\" attribute"); } try { var database = new SqDatabase <SqlConnection>(connection, ConnectionFactory, new TSqlExporter(SqlBuilderOptions.Default)); return(new DbManager(new MsSqlDbManager(database, connection.Database), connection, options)); } catch { connection.Dispose(); throw; }
public DbManager(IDbStrategy database, DbConnection connection, GenTablesOptions options) { this.Database = database; this._connection = connection; this._options = options; }