Basic concepts of Operations
Table of Contents
In this article, the basic concepts of Operations are explained.
Operations work
In terms of the MVC concept, the Operations could be called the Controllers. The Forms would be the Views and the Database would be the Model.
An operation does "the work". The operation can read information from the database and present that by passing information to one or more forms. Forms are external classes that are connected to the operation. In some cases the form is incorporated inside the class of the operation itself.
See for more information about the connection between forms and operations: Forms
In AI-Framework, operations are used for the standard functions, but also to build a base which other inherit from, and an operation that inherits from an interface (See ... ).
Below you find examples of these options.
Code examples
Example 1: The average operation
public InvoiceOverviewOp(IDbDefinition database, IExpression<IDbKey<User>> userKey)
: base(database)
{
RegisterInputParameter(UserKey, userKey);
}
protected override IForm CreateStartupForm()
{
return new InvoiceOverviewFrm(this);
}
public IProperty<IDbKey<User>> UserKey => ValueProperty(Database.GetTable<User>().PrimaryKey.Null);
Explanation of the code
- Line 1:
The operation is defined as a public method with the nameInvoiceOverviewOp.
The method has four parameters:database, of the interface type IDbDefinition.userKey,of the interface type IExpression, specifically an interface IDbKey of table User.inSelectionMode,of the type BooleanExpression.preSelectInvoiceNumber,of the type IntegerExpression.
- Line 3:
The parameterdatabaseis ... ? - Line 4-8:
The three remaining parameters are registered as input parameters and assigned to a property.- Example: the incoming parameter userKey (one capital) is assigned to the property UserKey (two capitals). This property is declared on line 15.
- Line 10-13:
- A form is connected to this operation.
- See also Forms
- Line 15-19:
This is the declaration of the properties that are assigned to the registered input parameters (line 4-8).public IProperty<IDbKey<User>> UserKey => ValueProperty(Database.GetTable<User>().PrimaryKey.Null);
The IExpression<IDbKey<User>>userKeyis declared to be public ValueProperty, namely a NULL value of the PrimaryKey of the table User from Database.
See also Forms
See also the Tutorial: Setting up an operation and a form