How can I fetch entities that has not been saved into another table?

Hello,

Obligation (Table obligations)
Obligation_Ajustment (Table obligation_adjustments)

Obligation and Obligation_Adjustments class are similar and share ID and POLICY_ID field.

I would like to get a list of entities that are not adjusted. In SQL it will looks like:
Select * from Obligation where obligation.Policy_Id is not in (Select Distinct Policy_Id) from obligation_adjustments).

I have no clue on how to do this with Aurelius.
Hereunder a pseudo code on how I'm doing this. it's not efficient and it is tacking a lot of time (50 000 records):

ObligationList := Manager.Find<TObligation>.List;
For Obligation in ObligationList do
begin
ObligationAdjustment := MAnager.Find<TobligationAdjustment>.Where(Linq['POLICY_ID] = Obligation.Policy_ID).Take(1).UniqueResult;

if not(assigned(ObligationAdjustment)) then
begin
//do all my stuff
End;
end;

Can you please help me ?

You can use Sql condition to add the condition part in raw SQL, as described in these Support Center topics:

Thanks a lot, that helped to solve my problem (I didn't catch it in the documentation). Enjoy your weekend.

Kind regards
Stephane

1 Like

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