Removing objects from list

Hello!

I have an object that has a list of child objects, simplified:


  [Entity]
  [Table('doc_headers')]
  [Id('FId', TIdGenerator.IdentityOrSequence)]
  TDocument = class(TBaseObject)
  private
    [Column('ID')]
    FId: integer;

    [ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAllRemoveOrphan, 'FDocument')]
    [OrderBy('DateEntry')]
    FPayments: Proxy<TList<TPayment>>;
  end;

  [Entity]
  [Table('payments')]
  [Id('FId', TIdGenerator.IdentityOrSequence)]
  TPayment = class
  private
    [Column('ID')]
    FId: integer;

    [Column('PAYMENT_VALUE')]
    FValue: double;

    [Association([TAssociationProp.Lazy], [TCascadeType.SaveUpdate, TCascadeType.Merge, TCascadeType.Refresh, TCascadeType.Flush])]
    [JoinColumn('LINK', [], 'ID')]
    FDocument: Proxy<TDocument>;
  end;

What is the best to remove an object from the parent's list? For example I have a TDocument that has 3 TPayment in the list (let's ssay with ID = 1, 2 and 3). I want to remove the object with the ID=2. What would be the correct way to do this?

Also, is there any helper to find the object in the list or I have to iterate through the list to find the object by the Id ?

That's just pure Delphi code, indeed just iterate through the list, find the object you want and call List.Remove or List.Delete to remove it.

Ok, thank you.

I hoped there are any helpers for this.. :) (yes, a little bit lazy here.. )

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