How to find Entity from classname

Hello,

The entity is registrated with RegisterEntity.
But how can I get the entity class from string name.

Something like GetClassFromRegisterEntity(aClassName)?
Is there a function to get the class of the registrated entities?
Or must I registrate the class with Classes.RegisterClass and then get it with Classes.FindClass



  [Entity]
  [Table('CUSTOMERS')]
  TCustomer = class (TInterfacedObject)
  end;
  ...
  initialization
    RegisterEntity(TCustomer);

  end.



function GetItem(aClassName: String; aID: Integer): <T>
var
  oClass: TClass;
begin
  oClass:= GetClassFromRegisterEntity(aClassName); // --> Can I get the class from the RegisterEntity?
 
end



Regards,
Christophe



You have the regular Delphi options. Indeed, you can simply call Classes.RegisterClass and then FindClass. Or, you can also use Delphi RTTI and use TRttiContext.GetType method.

Thanks, Wagner.

It is not possible to get it from the RegisterEntity?

Hi Christophe, no, RegisterEntity does simply nothing, it just guarantees that class is used and thus not removed from the linker.