Entity collections are representations of a database table in memory. An entity is one record within this collection. In the AI-Framework, data manipulation is done in memory and then it automatically updates the actual database. Entities are more than just a copy of data on disk in memory. They contain additional properties and methods. This adds a functional approach to data manipulation.
More technical details about entities and their properties and methods are found in Modelling > Programming > Entities > Entities
In this article, we will see how to set up an entity and use it in the model. When talking about 'setting up an entity', the model entity is in mind. There is also a generated entity, which is automatically generated.
The AI-Framework has two levels of entities.
An entity in the AI-Framework is based upon a record from a database table. To be more precise: An entity in the model of the AI-Framework inherits from an automatically generated entity (see above), which is based on a database table. Every single table that is used in the (model) software can have one or more records and any record can have one or more entities. When the data of this table needs to be accessed, it is done by loading the entity collection. The AI-Framework then automatically connects to the database and finds what is needed from the data table.
The strength of working with entities in the AI-Framework lies in the properties and methods that can be associated with the data.
Note: The properties and methods in the model entity are defined in one file. These properties and methods will then be available for each single entity (record) that is based on the loaded entity collection. So the CalculatedBooleanProperty named IsLowOnStock will be calculated afresh (and may be different) for each different entity (record).
Simplified code example:
new If(Stock.IsLowOnStock)
{
...
},
The Boolean IsLowOnStock has been defined in the model entity and is available and updated live each time the Boolean is needed.
Summarised, properties and methods make accurate information available straight from the entity. This means the logic has been lifted up to the level of the data, which makes it easier for the programmer to write the operations of the model.
In the following part, we will set up a database table, look at the generated entity and then set up an entity that inherits from this generated entity.
...
Once the entity has been properly set up, it can be used in many different ways. ...
The volatile ...
See also ...
A special type of entities are the summaries ...
See also ...
Article ID: 171
Created: Wed, Aug 28, 2019
Last Updated: Tue, Jan 28, 2020
Online URL: https://wiki-ai-framework.abstract-it.nl/article/entities-171.html