Interface IOrpheusDatabase
- Namespace
- OrpheusInterfaces.Core
- Assembly
- OrpheusInterfaces.dll
Orpheus database access component.
public interface IOrpheusDatabase : IDisposable
- Inherited Members
Properties
Connected
State of the database. Connected or not.
bool Connected { get; }
Property Value
- bool
True if database is connected
ConnectionFactory
The connection factory this database was constructed with, if any. DDL helpers use it to open auxiliary connections (schema introspection, administrative/system-database access) that share the same pooling configuration as the main connection. Null if this database was constructed from a raw IDbConnection instead of a connection factory.
IOrpheusConnectionFactory ConnectionFactory { get; }
Property Value
ConnectionString
Gets the underlying IDbConnection connection string.
string ConnectionString { get; }
Property Value
- string
The database connection string.
DDLHelper
Helps execute DDL specific commands for the underlying db engine.
IOrpheusDDLHelper DDLHelper { get; set; }
Property Value
- IOrpheusDDLHelper
An OrpheusDDLHelper instance.
DatabaseConnectionConfiguration
IDatabaseConnectionConfiguration DatabaseConnectionConfiguration { get; set; }
Property Value
- IDatabaseConnectionConfiguration
Database connection configuration.
DbConnection
IDbConnection DbConnection { get; }
Property Value
- IDbConnection
Exposing the underlying IDbConnection instance.
LastActiveTransaction
IDbTransaction LastActiveTransaction { get; }
Property Value
- IDbTransaction
Last active transaction.
Modules
List of registered Orpheus modules.
List<IOrpheusModule> Modules { get; }
Property Value
- List<IOrpheusModule>
Modules that are part in the database
TypeMap
Mapping dictionary of types to data types.
Dictionary<Type, DbType> TypeMap { get; }
Property Value
- Dictionary<Type, DbType>
Type map dictionary between types and DbType.
Methods
BeginTransaction()
Creates a transaction object.
IDbTransaction BeginTransaction()
Returns
- IDbTransaction
Returns a transaction instance
BeginTransactionAsync(CancellationToken)
Asynchronously creates a transaction object.
Task<IDbTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
CommitTransaction(IDbTransaction)
Commits a transaction.
void CommitTransaction(IDbTransaction transaction)
Parameters
transactionIDbTransactionTransaction to be committed.
CommitTransactionAsync(IDbTransaction, CancellationToken)
Asynchronously commits a transaction.
Task CommitTransactionAsync(IDbTransaction transaction, CancellationToken cancellationToken = default)
Parameters
transactionIDbTransactioncancellationTokenCancellationToken
Returns
Connect(IDatabaseConnectionConfiguration)
Connects to the database engine defined in the configuration object.
void Connect(IDatabaseConnectionConfiguration databaseConnectionConfiguration)
Parameters
databaseConnectionConfigurationIDatabaseConnectionConfigurationThe database connection configuration.
Connect(string)
Connects to the database engine defined in the connection string.
void Connect(string connectionString = null)
Parameters
connectionStringstringThe connection string.
ConnectAsync(string, CancellationToken)
Asynchronously connects to the database engine.
Task ConnectAsync(string connectionString = null, CancellationToken cancellationToken = default)
Parameters
connectionStringstringcancellationTokenCancellationToken
Returns
CreateCommand()
Create a DbCommand.
IDbCommand CreateCommand()
Returns
- IDbCommand
A DbCommand instance.
CreateModule(IOrpheusModuleDefinition)
Creates an OrpheusModule.
IOrpheusModule CreateModule(IOrpheusModuleDefinition definition = null)
Parameters
definitionIOrpheusModuleDefinitionModule definition
Returns
- IOrpheusModule
An IOrpheusModule instance
CreateModuleDefinition()
Creates an OrpheusModuleDefinition.
IOrpheusModuleDefinition CreateModuleDefinition()
Returns
- IOrpheusModuleDefinition
An IOrpheusModuleDefinition instance.
CreatePreparedQuery(string)
Returns a prepared query with parameters created.
IDbCommand CreatePreparedQuery(string SQL)
Parameters
SQLstringSQL for the prepared query
Returns
- IDbCommand
A DbCommand instance.
CreatePreparedQuery(string, List<string>, List<object>)
Returns a prepared query with parameters created.
IDbCommand CreatePreparedQuery(string SQL, List<string> parameters, List<object> parameterValues = null)
Parameters
SQLstringSQL for the prepared query
parametersList<string>SQL parameters
parameterValuesList<object>SQL parameter values
Returns
- IDbCommand
A DbCommand instance.
CreateSchema(Guid, string, double, string)
Creates a schema object and sets it's database.
ISchema CreateSchema(Guid id, string description, double version, string name = null)
Parameters
idGuidSchema id
descriptionstringSchema description
versiondoubleSchema version
namestringSchema name.From the supported db engines, only SQL server has support for named schema's.
Returns
- ISchema
An ISchema instance.
CreateTableKeyField()
Creates an OrpheusTableKeyField.
IOrpheusTableKeyField CreateTableKeyField()
Returns
- IOrpheusTableKeyField
An IOrpheusTableKeyField instance.
CreateTableOptions()
Creates an OrpheusTableOptions.
IOrpheusTableOptions CreateTableOptions()
Returns
- IOrpheusTableOptions
An IOrpheusTableOptions instance.
CreateTable<T>()
Creates a table and sets its database,using the type name as the table name.
IOrpheusTable<T> CreateTable<T>()
Returns
Type Parameters
TTable model type.
CreateTable<T>(IOrpheusTableOptions)
Creates a table and sets its database.
IOrpheusTable<T> CreateTable<T>(IOrpheusTableOptions options)
Parameters
optionsIOrpheusTableOptionsTable options
Returns
- IOrpheusTable<T>
An Orpheus table instance.
Type Parameters
TModel type for table
CreateTable<T>(string, List<IOrpheusTableKeyField>)
Creates a table and sets its database.
IOrpheusTable<T> CreateTable<T>(string tableName, List<IOrpheusTableKeyField> keyFields = null)
Parameters
tableNamestringTable name
keyFieldsList<IOrpheusTableKeyField>Table key fields
Returns
- IOrpheusTable<T>
An Orpheus table instance.
Type Parameters
TModel type for the table
DDLHelperAs<T>()
Casts the DDL helper to the specified type.
T DDLHelperAs<T>()
Returns
- T
An instance of T.
Type Parameters
TType in which to cast the DDLHelper. Must be a descendant of IOrpheusDDLHelper.
Disconnect()
Disconnects from the database engine.
void Disconnect()
DisconnectAsync()
Asynchronously disconnects from the database engine.
Task DisconnectAsync()
Returns
ExecuteDDL(string)
Executes a DDL command.
bool ExecuteDDL(string DDLCommand)
Parameters
DDLCommandstringDbCommand to run.
Returns
- bool
True if command was successfully executed.
ExecuteDDLAsync(string, CancellationToken)
Asynchronously executes a DDL command.
Task<bool> ExecuteDDLAsync(string DDLCommand, CancellationToken cancellationToken = default)
Parameters
DDLCommandstringcancellationTokenCancellationToken
Returns
GetTableCount(string)
long GetTableCount(string tableName)
Parameters
tableNamestringName of the table.
Returns
- long
Returns the row count of a table.
GetTableCount<T>()
long GetTableCount<T>()
Returns
- long
Returns the row count of a table.
Type Parameters
TThe table type name, will be used as the table name.
IsNullableType(Type)
Returns true if the type is a nullable type.
bool IsNullableType(Type type)
Parameters
typeTypeType
Returns
- bool
True if type is nullable
RegisterModule(IOrpheusModule)
Register an Orpheus module to the database.
void RegisterModule(IOrpheusModule module)
Parameters
moduleIOrpheusModuleModule to be registered
RollbackTransaction(IDbTransaction)
Rolls back a transaction.
void RollbackTransaction(IDbTransaction transaction)
Parameters
transactionIDbTransactionTransaction to be rolled-back.
RollbackTransactionAsync(IDbTransaction, CancellationToken)
Asynchronously rolls back a transaction.
Task RollbackTransactionAsync(IDbTransaction transaction, CancellationToken cancellationToken = default)
Parameters
transactionIDbTransactioncancellationTokenCancellationToken
Returns
SQLAsync<T>(IDbCommand, string, CancellationToken)
Asynchronously executes a prepared DbCommand and returns the result as typed models.
Task<List<T>> SQLAsync<T>(IDbCommand dbCommand, string tableName = null, CancellationToken cancellationToken = default)
Parameters
dbCommandIDbCommandtableNamestringcancellationTokenCancellationToken
Returns
Type Parameters
T
SQLAsync<T>(string, string, CancellationToken)
Asynchronously executes a SQL statement and returns the result as typed models.
Task<List<T>> SQLAsync<T>(string SQL, string tableName = null, CancellationToken cancellationToken = default)
Parameters
SQLstringtableNamestringcancellationTokenCancellationToken
Returns
Type Parameters
T
SQL<T>(IDbCommand, string)
Executes a db command and returns it as specific model.
List<T> SQL<T>(IDbCommand dbCommand, string tableName = null)
Parameters
dbCommandIDbCommandDbCommand to run.
tableNamestringOptionally set the table name, for which the query will run.
Returns
- List<T>
A list of 'T'
Type Parameters
T
SQL<T>(string, string)
Executes a SQL statement and returns it as specific model.
List<T> SQL<T>(string SQL, string tableName = null)
Parameters
Returns
- List<T>
A list of 'T'
Type Parameters
T