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>>;