I finally created a service function for the above:
function Tmyinterface.GetEntity(const classnam:string; const ids:TArray<Integer>): Tobject;
var obj:Tobjectmanager; clazz:tclass; ctx: TRttiContext; typ: TRttiType; list: TArray<TRttiType>;
begin
obj:=TXDataOperationContext.Current.GetManager;
clazz:=getclass(classnam);
if not assigned(clazz) then begin
ctx:=TRttiContext.Create; try
list:=ctx.GetTypes;
for typ in list do
begin
if typ.IsInstance and (EndsText(classnam, typ.Name)) then
begin
clazz:=typ.AsInstance.MetaClassType;
break;
end;
end;
finally ctx.Free; end;
end;
if assigned(clazz) then result:=obj.Find(clazz,ids) else result:=nil; end;
If the entity class can be retrieved from XData module without querying the Rtti, it could be better.
Having registered teh class with Registerclass, it can retrieved with just GetClass(classnam)