- This topic has 2 replies, 2 voices, and was last updated 6 years, 6 months ago by .
Viewing 2 reply threads
Viewing 2 reply threads
- You must be logged in to reply to this topic.
Home › Forums › kbmMW › [Request] Is there a way to add 'Custom' Field Generator in the rtti attributes?
Hi I want to make a smal request if you can add an additional param to the generator attribute of a table class, to a reference to an class method or anonymous method, so there you can pass as param the current ORM instance managing the object, the instance of the object itself and a returning value.
Example
[kbmMW_Table(‘name:person, index:{name:i1,field:name,descending:false}, index:{name:i2,unique:true,fields:[{name:name,descending:true},{name:age}]’)]
TPerson = class
private
FID:kbmMWNullable<string>;
FName:kbmMWNullable<string>;
FAddress:kbmMWNullable<string>;
FAge:kbmMWNullable<integer>;
public
[kbmMW_Field(‘name:id, primary:true, generator:CUSTOM’,ftString,40,
PROCEDURE (aORM: TkbmMWORM; aObject: TPerson; var aValue: TValue)
begin
…
end)]
property ID:kbmMWNullable<string> read FID write FID;
[kbmMW_Field(‘name:name’,ftWideString,50)]
property FullName:kbmMWNullable<string> read FName write FName;
[kbmMW_Field(‘name:address’,ftWideString,50)]
property Address:kbmMWNullable<string> read FAddress write FAddress;
[kbmMW_Field(‘name:age’,ftInteger)]
property Age:kbmMWNullable<integer> read FAge write FAge;
end;
Hi,
I understand the requirement for custom generators. I will look into it.
Thanks Kim, it can also be a method of the current class, but don’t know a way it can be called/specified in the the attributes. That will help because we can use the ‘self’ passed to the method to use directly the class instead of Casting it.
regards