Hi,
I need help understanding the concept of associations. Assume I have the following entity class:
[Entity]
[Table('sys_menu_group')]
[UniqueKey('smg_name')]
[Id('Fsmg_id', TIdGenerator.Uuid36)]
Tsys_menu_group = class
private
[Column('smg_id', [TColumnProp.Required], 36)]
Fsmg_id: string;
[Column('smg_basis_group_id', [], 36)]
Fsmg_basis_group_id: Nullable<string>;
...
[Association([TAssociationProp.Lazy], [])]
[JoinColumn('smg_basis_group_id', [], 'smg_id')]
Fbasis_group: Proxy<Tsys_menu_group>;
function Getbasis_group: Tsys_menu_group;
procedure Setbasis_group(const Value: Tsys_menu_group);
public
constructor Create;
destructor Destroy; override;
property smg_id: string read Fsmg_id write Fsmg_id;
property smg_basis_group_id: Nullable<string> read Fsmg_basis_group_id write Fsmg_basis_group_id;
...
property basis_group: Tsys_menu_group read Getbasis_group write Setbasis_group;
end;
function Tsys_menu_group.Getbasis_group: Tsys_menu_group;
begin
Result := Fbasis_group.Value;
end;
procedure Tsys_menu_group.Setbasis_group(const Value: Tsys_menu_group);
begin
Fbasis_group.Value := Value;
end;
I am creating a new object like this:
MenuGroup := Tsys_menu_group.Create;
MenuGroup.smg_basis_group_id := ...
...
I want to access and use the basis_group property right after creating, so I additional assign the corresponding object to the basis_group property. I think that this should automatically be done by the object manager when accessing the field?
Later on when saving the data using SaveOrUpdate() I get an exception with the message "Column 'smg_basis_group_id' specified twice.".
I tried some variations of field annotations but nothing worked. Do I have to remove the field Fsmg_basis_group_id? But how can I use it without using (and loading) the complete basis_group?
Thanks and regards