Table of Contents

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

IOrpheusConnectionFactory

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

cancellationToken CancellationToken

Returns

Task<IDbTransaction>

CommitTransaction(IDbTransaction)

Commits a transaction.

void CommitTransaction(IDbTransaction transaction)

Parameters

transaction IDbTransaction

Transaction to be committed.

CommitTransactionAsync(IDbTransaction, CancellationToken)

Asynchronously commits a transaction.

Task CommitTransactionAsync(IDbTransaction transaction, CancellationToken cancellationToken = default)

Parameters

transaction IDbTransaction
cancellationToken CancellationToken

Returns

Task

Connect(IDatabaseConnectionConfiguration)

Connects to the database engine defined in the configuration object.

void Connect(IDatabaseConnectionConfiguration databaseConnectionConfiguration)

Parameters

databaseConnectionConfiguration IDatabaseConnectionConfiguration

The database connection configuration.

Connect(string)

Connects to the database engine defined in the connection string.

void Connect(string connectionString = null)

Parameters

connectionString string

The connection string.

ConnectAsync(string, CancellationToken)

Asynchronously connects to the database engine.

Task ConnectAsync(string connectionString = null, CancellationToken cancellationToken = default)

Parameters

connectionString string
cancellationToken CancellationToken

Returns

Task

CreateCommand()

Create a DbCommand.

IDbCommand CreateCommand()

Returns

IDbCommand

A DbCommand instance.

CreateModule(IOrpheusModuleDefinition)

Creates an OrpheusModule.

IOrpheusModule CreateModule(IOrpheusModuleDefinition definition = null)

Parameters

definition IOrpheusModuleDefinition

Module 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

SQL string

SQL 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

SQL string

SQL for the prepared query

parameters List<string>

SQL parameters

parameterValues List<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

id Guid

Schema id

description string

Schema description

version double

Schema version

name string

Schema 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

IOrpheusTable<T>

Type Parameters

T

Table model type.

CreateTable<T>(IOrpheusTableOptions)

Creates a table and sets its database.

IOrpheusTable<T> CreateTable<T>(IOrpheusTableOptions options)

Parameters

options IOrpheusTableOptions

Table options

Returns

IOrpheusTable<T>

An Orpheus table instance.

Type Parameters

T

Model 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

tableName string

Table name

keyFields List<IOrpheusTableKeyField>

Table key fields

Returns

IOrpheusTable<T>

An Orpheus table instance.

Type Parameters

T

Model 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

T

Type 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

Task

ExecuteDDL(string)

Executes a DDL command.

bool ExecuteDDL(string DDLCommand)

Parameters

DDLCommand string

DbCommand 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

DDLCommand string
cancellationToken CancellationToken

Returns

Task<bool>

GetTableCount(string)

long GetTableCount(string tableName)

Parameters

tableName string

Name 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

T

The 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

type Type

Type

Returns

bool

True if type is nullable

RegisterModule(IOrpheusModule)

Register an Orpheus module to the database.

void RegisterModule(IOrpheusModule module)

Parameters

module IOrpheusModule

Module to be registered

RollbackTransaction(IDbTransaction)

Rolls back a transaction.

void RollbackTransaction(IDbTransaction transaction)

Parameters

transaction IDbTransaction

Transaction to be rolled-back.

RollbackTransactionAsync(IDbTransaction, CancellationToken)

Asynchronously rolls back a transaction.

Task RollbackTransactionAsync(IDbTransaction transaction, CancellationToken cancellationToken = default)

Parameters

transaction IDbTransaction
cancellationToken CancellationToken

Returns

Task

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

dbCommand IDbCommand
tableName string
cancellationToken CancellationToken

Returns

Task<List<T>>

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

SQL string
tableName string
cancellationToken CancellationToken

Returns

Task<List<T>>

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

dbCommand IDbCommand

DbCommand to run.

tableName string

Optionally 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

SQL string

SQL command to execute.

tableName string

Table name.

Returns

List<T>

A list of 'T'

Type Parameters

T