Question about how to return ClassType or ClassRef

Is a syntax of this kind possible with Aurelius?

The version below does not work with an error

E2531 Method 'Find' requires explicit type argument(s)

function TAureliusService.DeleteRecord(aID: Integer; aTableName: String):
Boolean;
var
aEntity: TObject;
aClass: TPersistentClass;
begin
Result := false;
aClass:= GetClass('T' + aTableName);
if aClass <> Nil then
aEntity:= Manager.Find.WHERE(TLinq.Eq('ID', aID)).UniqueResult;
if Assigned(aEntity) then
begin
Manager.Remove(aEntity);
Result:= true;
end;
end;

But I would hope it might be possible to dynamically assign the aEntity rather than having to write a separate method for the deletion of every Entity class.

It's possible, use

aEntity := Manager.Find(aClass).Where((TLinq.Eq('ID', aID)).UniqueResult;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.