Reputation: 23
I'm working with an ORM (Aurelius), and need to cast a object as TRttiType.
The TRttiType was obtained from TRtticontext.FindType.
ISptModel = interface(IInterface)
['{688431B1-2895-4FE2-AD18-8A7892289956}']
end;
TCidade = class(TInterfacedObject, ISptModel)
end;
var
FObjectInstance: ISptModel;
LType := LContext.FindType('Spt.Cidade.Model.TCidade');
Manager.SaveOrUpdate(LType(FObjectInstance)); // I need something like this, but doesnt work
Manager.SaveOrUpdate(TCidade(FObjectInstance)); // This works
It has to be cast as TCidade so Aurelius can persist the object correctly.
Upvotes: 1
Views: 192
Reputation: 1106
You cannot use LType
like you want to.
You probably just need to cast the interface as a TObject
like so:
Manager.SaveOrUpdate(FObjectInstance as TObject);
Upvotes: 1