This is one of the classes generated by ModelMaker
[Entity] [Table('PaymentType')] [UniqueKey('accountInfo')] [Id('FpaymentTypeId', TIdGenerator.IdentityOrSequence)] TPaymentType = class private [Column('paymentTypeId', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])] FpaymentTypeId: Integer; [Column('depositAmount', , 50)] FdepositAmount: Nullable<string>; [Association(, CascadeTypeAll - [TCascadeType.Remove])] [JoinColumn('accountInfo', , 'bankAccountTypeId')] FaccountInfo: TBankAccountType; [Column('version', )] [Version] Fversion: integer; public property paymentTypeId: Integer read FpaymentTypeId write FpaymentTypeId; property depositAmount: Nullable<string> read FdepositAmount write FdepositAmount; property accountInfo: TBankAccountType read FaccountInfo write FaccountInfo; property version: integer read Fversion write Fversion; end;
accountInfo is a property that I need to create an instance of the class if I want to assign data to it, but theres no destructor to free it if it exists when I dispose of the TPaymentType class.
Do these need to be destroyed manually eg
var o: TPaymentType; o := GetSomePaymentTypeClass; if assigned(o.accountInfo) then o.accountInfo.Free; o.Free;
or is there an option to generate code to free these in a destructor for me ? I've looked for an option but couldn't find one. Some of my classes contain deep hierarchies and could be difficult to free manually. The only other alternative I could see would be to code a procedure that takes the object and uses RTTI to traverse the properties and free any that needed freeing.