Table of Contents

Class OrpheusModule

Namespace
OrpheusCore
Assembly
OrpheusCore.dll

OrpheusModule class represents a logical division and grouping of a set of tables. For example you can an OrdersModule, which will be comprised from many different tables. Orders,Customers,OrderLines etc. When you Save from the module level, all pending records in tables that belong to the module, will be saved as well. All master-detail relationships and keys will be updated automatically.

public class OrpheusModule : IOrpheusModule
Inheritance
OrpheusModule
Implements
Inherited Members

Constructors

OrpheusModule(IOrpheusDatabase, ILogger<IOrpheusModule>)

Initializes a new instance of the OrpheusModule class. OrpheusModule class represents a logical division and grouping of a set of tables. For example you can an OrdersModule, which will be comprised from many different tables. Orders,Customers,OrderLines etc. When you Save from the module level, all pending records in tables that belong to the module, will be saved as well. All master-detail relationships and keys will be updated automatically.

public OrpheusModule(IOrpheusDatabase database, ILogger<IOrpheusModule> logger)

Parameters

database IOrpheusDatabase

The database.

logger ILogger<IOrpheusModule>

The logger

OrpheusModule(IOrpheusDatabase, IOrpheusModuleDefinition, ILogger<IOrpheusModule>)

Initializes a new instance of the OrpheusModule class. OrpheusModule class represents a logical division and grouping of a set of tables. For example you can an OrdersModule, which will be comprised from many different tables. Orders,Customers,OrderLines etc. When you Save from the module level, all pending records in tables that belong to the module, will be saved as well. All master-detail relationships and keys will be updated automatically.

public OrpheusModule(IOrpheusDatabase database, IOrpheusModuleDefinition definition, ILogger<IOrpheusModule> logger)

Parameters

database IOrpheusDatabase

The database.

definition IOrpheusModuleDefinition

The definition.

logger ILogger<IOrpheusModule>

The logger

Properties

Database

public IOrpheusDatabase Database { get; }

Property Value

IOrpheusDatabase

Module's database.

Definition

public IOrpheusModuleDefinition Definition { get; }

Property Value

IOrpheusModuleDefinition

Module's definition.

MainTable

public IOrpheusTable MainTable { get; set; }

Property Value

IOrpheusTable

The module's main table.

ReferenceTables

public List<IOrpheusTable> ReferenceTables { get; }

Property Value

List<IOrpheusTable>

List of module's reference tables. Reference tables are auxiliary or lookup tables.

Tables

public List<IOrpheusTable> Tables { get; }

Property Value

List<IOrpheusTable>

List of module's tables.

Methods

ClearData()

Clears data from all module tables.

public void ClearData()

GetReferenceTable<T>()

Gets a table by model. Uses the model class name as the table name.

public IOrpheusTable<T> GetReferenceTable<T>()

Returns

IOrpheusTable<T>

Type Parameters

T

Table type.

GetReferenceTable<T>(int)

Gets a reference table by index for a model

public IOrpheusTable<T> GetReferenceTable<T>(int index)

Parameters

index int

Table index.

Returns

IOrpheusTable<T>

Type Parameters

T

Table type.

GetReferenceTable<T>(string)

Gets a reference table by name for a model

public IOrpheusTable<T> GetReferenceTable<T>(string tableName)

Parameters

tableName string

Table name.

Returns

IOrpheusTable<T>

Type Parameters

T

Table type.

GetTable<T>()

Gets a table by model. Uses the model class name as the table name.

public IOrpheusTable<T> GetTable<T>()

Returns

IOrpheusTable<T>

Type Parameters

T

Table type.

GetTable<T>(int)

Gets a reference table by index for a model

public IOrpheusTable<T> GetTable<T>(int index)

Parameters

index int

Table index.

Returns

IOrpheusTable<T>

Type Parameters

T

Table type

GetTable<T>(string)

Gets a table by name for a model

public IOrpheusTable<T> GetTable<T>(string tableName)

Parameters

tableName string

Table name.

Returns

IOrpheusTable<T>

Type Parameters

T

Table type.

Load(Dictionary<string, List<object>>, LogicalOperator, bool)

Loads records from the DB to the table. You can configure having multiple fields and multiple values per field. Multiple field values are bound with a logical OR. Multiple fields by default are bound with a logical OR. Defining a logical operator, you can change the default behavior. This applies only for the MainTable.

public void Load(Dictionary<string, List<object>> keyValues, LogicalOperator logicalOperator = LogicalOperator.loOR, bool clearExistingData = true)

Parameters

keyValues Dictionary<string, List<object>>

The key values.

logicalOperator LogicalOperator

The logical operator.

clearExistingData bool

If true, it will clear all existing data. Default is true.

Exceptions

Exception

If you want to load a record from the module level, you need to define the main table for the module.

Load(List<object>)

Loads a module's record from the database.

public void Load(List<object> keyValues = null)

Parameters

keyValues List<object>

The key values

Exceptions

Exception

If you want to load a record from the module level, you need to define the main table for the module.

Load(IDbCommand, bool)

Loads main table data by executing a db command.

public void Load(IDbCommand dbCommand, bool clearExistingData = true)

Parameters

dbCommand IDbCommand

The IDbCommand instance.

clearExistingData bool

If true, it will clear all existing data. Default is true.

Exceptions

Exception

If you want to load a record from the module level, you need to define the main table for the module.

Save()

Saves all changes to the database within a transaction.

public void Save()

Events

OnAfterSave

public event EventHandler<ISaveEventArguments> OnAfterSave

Event Type

EventHandler<ISaveEventArguments>

Occurs after the transaction has been committed.

OnBeforeSave

public event EventHandler<ISaveEventArguments> OnBeforeSave

Event Type

EventHandler<ISaveEventArguments>

Occurs before records are save in the database.