Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Multi-Model Design

Using Model attribute

Scroll Prev Top Next More

Defining multiple mapping models in Aurelius is very straightforward if you use Model attribute. Basically all you need to do is annotate a class with the model attribute telling Aurelius the model where that class belongs to. For example, the following code specifies that class TUserInfo belongs to model "Security":

 

// TUserInfo belongs to model "Security"
[Entity, Automapping]
[Model('Security')]
TUserInfo = class
  {...}

 

You can also include the class in multiple models, just by adding the Model attribute multiple times. The following example specifies that the class TSample belongs to both models "Security" and "Sample":

 

// TSample belongs to model "Security" and "Sample"
[Entity, Automapping]
[Model('Security')]
[Model('Sample')]
TSample = class
  {...}

 

In Aurelius, every mapped class belongs to a model. If you omit the Model attribute (since it's optional), the class will be included in the default model.

 

// This class belongs to default model
[Entity, Automapping]
TCustomer = class

  {...}

 

If you want to add a class to both default model and a different model, you can just add it to default model (named "Default"):

 

// TUser belongs to both "Security" and default model
[Entity, Automapping]
[Model('Security')]
[Model('Default')]
TUser = class

  {...}

 

You can then use the different models by retrieving the TMappingExplorer instance associated with a model.