Interface IOrpheusDDLHelper
- Namespace
- OrpheusInterfaces.Core
- Assembly
- OrpheusInterfaces.dll
Abstract definition of DDL helper. DDL helper is used to execute DB engine specific DDL commands.
public interface IOrpheusDDLHelper
Properties
ConnectionString
Builds the connection string.
string ConnectionString { get; }
Property Value
DB
Database for the DDL helper.
IOrpheusDatabase DB { get; set; }
Property Value
- IOrpheusDatabase
Database the helper is associated with
DatabaseName
Gets the database name.
string DatabaseName { get; }
Property Value
DbEngineType
Returns the underlying connection type.
DatabaseEngineType DbEngineType { get; }
Property Value
DelimitedIdentifierEnd
Identifiers that do not comply with all of the rules for identifiers must be delimited in a SQL statement, enclosed in the DelimitedIdentifier char.
char DelimitedIdentifierEnd { get; }
Property Value
- char
Char
DelimitedIdentifierStart
Identifiers that do not comply with all of the rules for identifiers must be delimited in a SQL statement, enclosed in the DelimitedIdentifier char.
char DelimitedIdentifierStart { get; }
Property Value
- char
Char
ModifyColumnCommand
Returns the DB specific modify table command.
string ModifyColumnCommand { get; }
Property Value
SupportsGuidType
Returns true if the DBEngine supports natively the Guid type.
bool SupportsGuidType { get; }
Property Value
- bool
True if the DBEngine supports natively the Guid type
SupportsSchemaNameSpace
Returns true if the DBEngine supports having schema name spaces. From the currently supported databases, only SQL has this feature.
bool SupportsSchemaNameSpace { get; }
Property Value
Methods
CreateDatabase()
Returns true if a database is successfully created using the underlying db engine settings.
bool CreateDatabase()
Returns
- bool
True if database was created successfully
CreateDatabase(string)
Returns true if a database is successfully created using the underlying db engine settings.
bool CreateDatabase(string dbName)
Parameters
dbNamestringDatabase name
Returns
- bool
True if the database was created successfully
CreateDatabaseWithDDL(string)
Returns true if a database is successfully created using the passed DDL script.
bool CreateDatabaseWithDDL(string ddlString)
Parameters
ddlStringstringDDL command
Returns
- bool
True if the database was created successfully
DatabaseExists(string)
Returns true the database exists.
bool DatabaseExists(string dbName)
Parameters
dbNamestringDatabase name
Returns
DbTypeToString(DbType)
Returns the db engine specific string equivalent, for a DbType enumeration.
string DbTypeToString(DbType dataType)
Parameters
dataTypeDbTypeDbType
Returns
- string
String value for the DbType
ExecuteBatchedInsertWithKeyRetrieval(string, List<string>, string, List<List<object>>, IDbTransaction)
Executes a batched INSERT of rows and returns the DB-generated key
value for each row, in the same order the rows were passed in. There is no ADO.NET-
portable way to retrieve generated keys from a multi-row insert, so implementations are
engine-specific (e.g. SQL Server uses MERGE+OUTPUT with a correlation column since plain
multi-row OUTPUT doesn't preserve input order; PostgreSQL uses INSERT...RETURNING, which
does preserve order; MySQL has no RETURNING and instead derives the range from
LAST_INSERT_ID()).
List<object> ExecuteBatchedInsertWithKeyRetrieval(string tableName, List<string> columns, string keyColumnName, List<List<object>> rows, IDbTransaction transaction)
Parameters
tableNamestringFully-qualified table name.
columnsList<string>Editable column names, in the order each row's values are provided.
keyColumnNamestringThe DB-generated key column to retrieve.
rowsList<List<object>>Each row's values, in column order, matching
columns.transactionIDbTransactionTransaction to execute within.
Returns
ExecuteBatchedInsertWithKeyRetrievalAsync(string, List<string>, string, List<List<object>>, IDbTransaction, CancellationToken)
Asynchronous counterpart of ExecuteBatchedInsertWithKeyRetrieval(string, List<string>, string, List<List<object>>, IDbTransaction).
Task<List<object>> ExecuteBatchedInsertWithKeyRetrievalAsync(string tableName, List<string> columns, string keyColumnName, List<List<object>> rows, IDbTransaction transaction, CancellationToken cancellationToken = default)
Parameters
tableNamestringcolumnsList<string>keyColumnNamestringrowsList<List<object>>transactionIDbTransactioncancellationTokenCancellationToken
Returns
SafeFormatAlterTableAddColumn(string, List<string>)
Properly formats an ALTER TABLE ADD COLUMN command for the underlying database engine.
string SafeFormatAlterTableAddColumn(string tableName, List<string> columnsToAdd)
Parameters
tableNamestringTable's name that schema is going to change
columnsToAddList<string>Columns for creation
Returns
SafeFormatAlterTableDropColumn(string, List<string>)
Properly formats an ALTER TABLE DROP COLUMN command for the underlying database engine.
string SafeFormatAlterTableDropColumn(string tableName, List<string> columnsToDelete)
Parameters
tableNamestringTable's name that schema is going to change
columnsToDeleteList<string>Columns for deletion
Returns
SafeFormatField(string)
Properly formats a field name, to be used in a SQL statement, in case the field name is a reserved word.
string SafeFormatField(string fieldName)
Parameters
fieldNamestringField name
Returns
- string
Safely formated field name
SchemaObjectExists(ISchemaConstraint)
Returns true if the schema object exists in the database.
bool SchemaObjectExists(ISchemaConstraint schemaConstraint)
Parameters
schemaConstraintISchemaConstraint
Returns
SchemaObjectExists(ISchemaObject)
Returns true if the schema object exists in the database. A schema object can be a table,view,primary key, stored procedure, etc.
bool SchemaObjectExists(ISchemaObject schemaObject)
Parameters
schemaObjectISchemaObjectSchema
Returns
- bool
True if the object exists
SchemaObjectExists(string)
Returns true if the schema object exists in the database. A schema object can be a table,view,primary key, stored procedure, etc.
bool SchemaObjectExists(string schemaObjectName)
Parameters
schemaObjectNamestringSchema
Returns
- bool
True if the object exists
SchemaObjectId<T>(ISchemaObject)
Gets the schema object, db engine assigned/generated, identifier.
T SchemaObjectId<T>(ISchemaObject schemaObject)
Parameters
schemaObjectISchemaObjectThe schema object.
Returns
- T
Type Parameters
T
TypeToString(Type)
Returns the db engine specific string equivalent, for a .net type
string TypeToString(Type type)
Parameters
typeTypeType
Returns
- string
String value for the mapped DbType