Hello my friends,
I'm creating my own ORM.
I use the class TCrateDB to verify if database exists. If database not exists, I create it.
After this, I use RTTI to read Custom Attributes in my business classes to populate SQL statements and create the table.
Now, I want use some way to populate the database with values default, like this:
Table UNITS (auxiliary of Table PRODUCTS)
ID | DESCRIPTION | ABBREVIATION
-----------------------------------------------------
1 | UNITY | UN
-----------------------------------------------------
2 | KILOGRAMA | KG
-----------------------------------------------------
3 | MILLILITER | ML
I think create a property with typekind TStringList with the values default.
Is there any way to retrieve the value of a property using RTTI?
I tried that way:
var
RCtx: TRttiContext;
RType: TRttiType;
Prop: TRttiProperty;
begin
RCtx := TRttiContext.Create;
try
RType := RCtx.GetType(aClass);
Prop := RType.GetProperty('Teste1');
ShowMessage(Prop.Name);
ShowMessage(Prop.GetValue("I do not know what to put here").ToString);
finally
RCtx.Free;
end;
end;
Any help will be most welcome.
Thank you.