Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Mapping

Attributes

Scroll Prev Top Next More

Object-Relational Mapping in Aurelius is done by using attributes. With this approach you can do your mapping directly when coding the classes, and by browsing the source code you can easily tell how the class is being mapped to the database.

 

Basically you just add attributes to the class itself, or to a field or property:

 

[Table('Customer')]
TMyCustomer = class
private
  [Column('Customer_Name')]
  FCustomerName: string;
...

 

For column and associations mapping Aurelius accepts mapping attributes in either class field or class property (but not both of course). We recommend using mapping attributes in fields whenever it's possible, for several reasons:

 

1. Attributes are kept in private section of your class, leaving the public section clean and easily readable

2. Fields represent better the current state of the object. Properties can have getter and setters based on other data that it's not exactly the object state for persistance.

3. Some Aurelius features are better suited for fields. For example, lazy-loaded associations requires the use of a Proxy type, which makes more sense to be uses in fields (although you can use it in properties)

 

Still, there are situations where creating mapping attributes in properties are interesting, when for example you want to save the result of a runtime calculation in database.

 

Available attributes (declared in unit Aurelius.Mapping.Attributes):

 

Basic Mapping

Entity

Id

Table

Column

Sequence

UniqueKey

Enumeration

 

Association Mapping

Association

JoinColumn

 

Many-Valued Association Mapping

ManyValuedAssociation

ForeignJoinColumn

 

Behavior Mapping

Where

OrderBy

Model

 

DB Structure Mapping

DBIndex

ForeignKey

 

Inheritance Mapping

Inheritance

DiscriminatorColumn

DiscriminatorValue

PrimaryJoinColumn

 

Automapping

Automapping

Transient

 

Concurrency Control

Version

 

Other attributes

Description