Show/Hide Toolbars

TMS Data Modeler Documentation

Navigation: TMS Aurelius Export > Customization Script

Adding OrderBy Attribute to Many-Valued Association

Scroll Prev Top Next More

This example adds the attribute [OrderBy] to the many-valued association. It identifies the many-valued association by the name of the generated private field (FEmployeesList) in a specific class (TEmployees):

 

procedure OnManyValuedAssociationGenerated(Args: TManyValuedAssociationGeneratedArgs);
begin                   
  case Args.CodeType.Name of
    'TEmployees'
       case Args.Field.Name of  
         'FEmployeesList'
           Args.Field.AddAttribute('OrderBy').AddRawArgument('''LAST_NAME,FIRST_NAME''');
       end;
  end;              
end;                                            

 

Suppose the original generated source code was this one:

 

    [ManyValuedAssociation([TAssociationProp.Lazy], [TCascadeType.SaveUpdate, TCascadeType.Merge], 'FReportsTo')]
    FEmployeesList: Proxy<TList<TEmployees>>;

 

With the script above, it will become this:

 

    [ManyValuedAssociation([TAssociationProp.Lazy], [TCascadeType.SaveUpdate, TCascadeType.Merge], 'FReportsTo')]
    [OrderBy('LAST_NAME,FIRST_NAME')]
    FEmployeesList: Proxy<TList<TEmployees>>;