public void SchemaDrop(string schemaName, bool force, bool throwIfNotExists) { if (String.IsNullOrWhiteSpace(schemaName)) { throw new ArgumentNullException(nameof(schemaName)); } try { var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.SchemaDrop(schemaName, force, throwIfNotExists)); var resp = new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); } catch (PostgresException pex) { if (pex.SqlState == "2BP01") { throw new DependentObjectsException(pex.Detail); } if (pex.SqlState == "3F000") { throw new SchemaDoesntExistsException(schemaName); } throw; } }
public Schema SchemaRename(string schemaName, string newSchemaName) { try { if (String.IsNullOrWhiteSpace(schemaName)) { throw new ArgumentNullException(nameof(schemaName)); } if (String.IsNullOrWhiteSpace(newSchemaName)) { throw new ArgumentNullException(nameof(newSchemaName)); } var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.SchemaRename(schemaName, newSchemaName)); var resp = new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); return(GetSchema(newSchemaName)); } catch (PostgresException pex) { if (pex.SqlState == "3F000") { throw new SchemaDoesntExistsException(schemaName); } if (pex.SqlState == "42P06") { throw new SchemaAlreadyExistsException(newSchemaName); } throw; } }
public Schema CreateSchema(string schemaName, bool throwIfAlreadyExists) { try { if (String.IsNullOrWhiteSpace(schemaName)) { throw new ArgumentNullException(nameof(schemaName)); } //schemaName = schemaName.ToLower(); var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.SchemaCreate(schemaName, throwIfAlreadyExists)); var resp = new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); return(GetSchema(schemaName)); } catch (PostgresException pex) { if (pex.SqlState == "42P06") { throw new SchemaAlreadyExistsException(schemaName); } throw; } }
public int ExecuteNonQuery(string sqlStatement) { var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(sqlStatement); return(ExecuteNonQuery(sqlCommand)); }
public TOut ExecuteScalar <TOut>(string sqlStatement) { var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(sqlStatement); return(ExecuteScalar <TOut>(sqlCommand)); }
public IEnumerable <JObject> ExecuteReader(string sqlStatement) { var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(sqlStatement); return(ExecuteReader(sqlCommand)); }
public void DomainDrop(string domainName, bool throwIfNotExists) { if (String.IsNullOrWhiteSpace(domainName)) { throw new ArgumentNullException(nameof(domainName)); } var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.DomainDrop(domainName, throwIfNotExists)); new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); }
public void ExtensionCreate(string extensionName, bool throwIfAlreadyExists) { if (String.IsNullOrWhiteSpace(extensionName)) { throw new ArgumentNullException(nameof(extensionName)); } var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.ExtensionCreate(extensionName, throwIfAlreadyExists)); new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); }
public void DomainCreate(string domainName, string postgresTypeName, bool throwIfExists) { if (String.IsNullOrWhiteSpace(domainName)) { throw new ArgumentNullException(nameof(domainName)); } var sqlCommand = new PgSqlCommand(); sqlCommand.AppendCommand(SQLStatements.DomainCreate(domainName, postgresTypeName)); if (!throwIfExists) { if (!DomainExists(domainName)) { new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); } } else { new DbExecuter(ConnectionString).ExecuteNonQuery(sqlCommand); } }