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
databaseIOrpheusDatabaseThe database.
loggerILogger<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
databaseIOrpheusDatabaseThe database.
definitionIOrpheusModuleDefinitionThe definition.
loggerILogger<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
Type Parameters
TTable type.
GetReferenceTable<T>(int)
Gets a reference table by index for a model
public IOrpheusTable<T> GetReferenceTable<T>(int index)
Parameters
indexintTable index.
Returns
Type Parameters
TTable type.
GetReferenceTable<T>(string)
Gets a reference table by name for a model
public IOrpheusTable<T> GetReferenceTable<T>(string tableName)
Parameters
tableNamestringTable name.
Returns
Type Parameters
TTable type.
GetTable<T>()
Gets a table by model. Uses the model class name as the table name.
public IOrpheusTable<T> GetTable<T>()
Returns
Type Parameters
TTable type.
GetTable<T>(int)
Gets a reference table by index for a model
public IOrpheusTable<T> GetTable<T>(int index)
Parameters
indexintTable index.
Returns
Type Parameters
TTable type
GetTable<T>(string)
Gets a table by name for a model
public IOrpheusTable<T> GetTable<T>(string tableName)
Parameters
tableNamestringTable name.
Returns
Type Parameters
TTable 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
keyValuesDictionary<string, List<object>>The key values.
logicalOperatorLogicalOperatorThe logical operator.
clearExistingDataboolIf 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
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
dbCommandIDbCommandThe IDbCommand instance.
clearExistingDataboolIf 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.