I'd like to retrieve a list of objects that contain objects from two entities without using inheritance. The list would be an outer join between the two entities. Consider
[Entity, Automapping]
TEmployee = class
private
FId: Integer;
FName: string;
public
property Id: Integer read FId write FId;
property Name: string read FName write FName;
end;
[Entity, Automapping]
TerminatedEmployee = class
private
FEmployee: TEmployee;
FTerminationDate: TDate;
public
property Employee: TEmployee read FEmployee write FEmployee;
property TerminationDate: TDate read FTerminationDate write FTerminationDate;
end;
TEmployee has many objects. TTerminatedEmployee has a few. How do I create an outer join between the two using TObjectManager?
For clarity, I want to create in Aurelius the equivalent of the following:
select a.id, a.Name, b.TerminationDate from Employee a left join TerminatedEmployee b on a.Id = b.employee;
I'd also like to do
select id, Name from Employee where id not in (select id from TerminatedEmployee)
wlandgraf
(Wagner Landgraf)
August 4, 2026, 10:44am
3
I assume you have an unique key in TerminatedEmployee that makes sure Employee_ID column there is unique, so you have a 1:1 mapping.
In this case I suggest you use this approach for 1:1 mapping:
You should always map a one-to-many, and then you can add wrappers to make your object behave as 1-1 at OOP-level:
TPerson = class
private
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll)]
FAddresses: Proxy<TList<TAddress>>;
public
property Address: TAddress read GetAddress write SetAddress;
end;
function TPerson.GetAddress: TAddress;
begin
if FAddresses.Value.Count > 0 then
Result := FAddresses.Value[0]
else
Result := nil;
end;
procedure TPerson.SetAddre…
After I made the post, I considered the solution you recommended. Thanks.