Entities


Basic concepts of Entities

Table of Contents

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.

 

Two levels of entities

The AI-Framework has two levels of entities.

  1. The generated entity
    When the model of a database table has been defined, and the code for that database table is generated, the AI-Framework will automatically build the generated entity. In it are all the fields of the table available.

  2. The model entity
    This model entity inherits from the generated entity. Apart from that this model entity is empty. It is in this entity that the model programmer in the AI-Framework adds extra properties and methods.

 

Why use an entity

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.

Simple example with a property in the entity

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.

Expanding the example by adding a method to the entity

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.

 

Setting up an entity

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.

...

Using an entity

Once the entity has been properly set up, it can be used in many different ways. ...

The volatile entity

The volatile ...

See also ...

Summaries

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