Table of Contents

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

string

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

string

DbEngineType

Returns the underlying connection type.

DatabaseEngineType DbEngineType { get; }

Property Value

DatabaseEngineType

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

string

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

bool

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

dbName string

Database 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

ddlString string

DDL command

Returns

bool

True if the database was created successfully

DatabaseExists(string)

Returns true the database exists.

bool DatabaseExists(string dbName)

Parameters

dbName string

Database name

Returns

bool

DbTypeToString(DbType)

Returns the db engine specific string equivalent, for a DbType enumeration.

string DbTypeToString(DbType dataType)

Parameters

dataType DbType

DbType

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

tableName string

Fully-qualified table name.

columns List<string>

Editable column names, in the order each row's values are provided.

keyColumnName string

The DB-generated key column to retrieve.

rows List<List<object>>

Each row's values, in column order, matching columns.

transaction IDbTransaction

Transaction to execute within.

Returns

List<object>

ExecuteBatchedInsertWithKeyRetrievalAsync(string, List<string>, string, List<List<object>>, IDbTransaction, CancellationToken)

Task<List<object>> ExecuteBatchedInsertWithKeyRetrievalAsync(string tableName, List<string> columns, string keyColumnName, List<List<object>> rows, IDbTransaction transaction, CancellationToken cancellationToken = default)

Parameters

tableName string
columns List<string>
keyColumnName string
rows List<List<object>>
transaction IDbTransaction
cancellationToken CancellationToken

Returns

Task<List<object>>

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

tableName string

Table's name that schema is going to change

columnsToAdd List<string>

Columns for creation

Returns

string

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

tableName string

Table's name that schema is going to change

columnsToDelete List<string>

Columns for deletion

Returns

string

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

fieldName string

Field name

Returns

string

Safely formated field name

SchemaObjectExists(ISchemaConstraint)

Returns true if the schema object exists in the database.

bool SchemaObjectExists(ISchemaConstraint schemaConstraint)

Parameters

schemaConstraint ISchemaConstraint

Returns

bool

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

schemaObject ISchemaObject

Schema

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

schemaObjectName string

Schema

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

schemaObject ISchemaObject

The 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

type Type

Type

Returns

string

String value for the mapped DbType