History of records changes

Automatic maintaining history of system objects records change. Allows to receive a cut of actual data for any date.

1. Order of inclusion in a versioning entity.

Step 1. At the main entity choose versioning type - Versioning of basic entity. Press the button to update tables with the version.

Step 2. At the subsidiary entity choose versioning type - Versioning of the connected entity. Press the button to update tables with the version.

2. Scheme of storage’s versions

Versions of basic sub entities (basic versioning) are stored in the table MetadataEntityVersion.

# Column Comment
1 BaseEntityId Id row
2 VersionNumber A number of version
3 DateFrom start date of the version’s action
4 DateTo expiry date of the version’s action (if null -the version is current)
5 Changes The serialized changes of attributes in the current version

Historical data are stored in the tables "N _".

For example, for the table Work -> N_Work.

ATTENTION! After inclusion versioning types of data need to be updated in the main table, in historical and it’s necessary to update metadata.

Additional attributes for the tables "N _"

Column Comment
1 VersioningEntityId Id entity
2 VersioningBaseEntityId Id base entity
3 VersionFrom The version of basic entity from
4 VersionTo The version of basic entity to (if null -record works in the current version)

As example we will consider the main entity Work (table Work) and the subordinated entity the Task (WorkTask). Entity Work has three versions 1, 2, 3. Version 3 - current.

Table N_Work has following data:

VersionFrom VersionTo
1 2
3

Table H_WorkTask has following data:

Task VersionFrom VersionTo
Task1 1 2
Task2 3
Task3 2 2
Task1 3

It means that:

  • version 1. Work was saved with Task 1.
  • version 2. The main record of work didn't change, Task 2 was added.
  • version 3. The main record of work changed. Task 3 was removed, Task2 was added, Task1 was changed.

3. Receiving history of change for output

Check an example of receiving history of change OptimaJet.DynamicEntities.DataSource.VersionFormatter.GetObjectHistoryInHtml.

In the DynamicDataSourceController controler the GetHistory method removes history of changes in HTML.

4. Manual creation of versions for basic and connected objects

Automatic creation of versions happens if we send requests for change of data through DynamicEntities.

If record was saved, changed or removed through other ORM, it is possible to update or create the version through class methods OptimaJet.DynamicEntities.DataSource.VersionCreator.