Show/Hide Toolbars

TMS Data Modeler Documentation

Navigation: TMS Aurelius Export

Customization Script

Scroll Prev Top Next More

You can fully customize the generated source code using the customization script, which you can write and debug from the Script Tab in the export dialog. Form information on how to edit and debug the script, please follow the Script Tab topic. This topic covers what code you can write from script and provide some code examples.


Event Handlers


The script is based on the concept of event handlers. When Data Modeler is creating the meta-information of the code, it can fire many events after each piece of code being generated. For example, when a database column is processed and a combination of class field/property is created, the event OnColumnGenerated is created. To handle such event, just declare a procedure in the script code with the same name, receiving a single param of type TColumnGeneratedArgs. From that parameter you can retrieve relevant context information and change/adapt the generate code for your own need.


Here is a list of the events fired by the source code generator:





Fired whenever a table column in processed and becomes a class field and property of a primitive type, and Column attribute is added to the class field.


Fired whenever an association is processed, i.e., when a database foreign key becomes a class field and property of type Proxy<T> and T, respectively, and attributes Association and JoinColumn are added to the class field.


Fired whenever a many-valued association is processed and becomes a class field/property of type TList<T> and ManyValuedAssociation attribute is added.


Fired after a class (entity) type has been fully generated.


Fired after the unit has been fully generated.



Code Samples


Some script samples for common customization tasks:

Adding OrderBy Attribute to Many-Valued Association

Adding Version Attribute to Class Fields

Creating a New Property in a Class

Creating a New Method Procedure in a Class

Creating a New Method Function in a Class

Adding a Unit Name to the Uses Clases

Changing Cascade of Many-Valued Association

Adding ForeignKey Attribute to Associations

Adding DBIndex Attributes From Table Indexes

Adding Schema Name to Table Attribute