Export Aurelius script OnAssociationGenerated

Hello Wagner,

1.) Is there a more elegant way to do something depending on Lazy or Eager Association?
It's about the "if" query

2.) I need the PrimaryKey Field of the parent table (property name, not DB name).
See "else" section

procedure OnAssociationGenerated(Args: TAssociationGeneratedArgs);
begin 
  [other code] 
  if Pos( 'Proxy', Args.Field.FieldType.BaseType) > 0 then  
    Func.AddSnippet('try Result := StringToGUID( F'+Args.Prop.Name+'.Key); except Result := SNull; end;')
  else
    Func.AddSnippet('Result := F'+Args.Prop.Name+'.'+Args.DBRelationship.ParentTable.TableCaption+'ID'+';');  
  [other code]
end;

This solution shown here works, but depends on certain definitions in our development and is therefore not generally valid.

Thank you

I think the test is fine. You could test for Proxy< to make sure you don't use associations which have "Proxy" in their name, although I doubt you would have it.

Unfortunately such information is not available. But if you have your tables standardized, wouldn't you just need to the ID? I mean won't the final code be:

  Result := FAssociatedObject.Id;

?

Thank you,
yes, they are standardized.

Entityname+'ID' :wink:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.