我有一个基类
TPart = class
private
FPartId: Integer;
public
property PartId: Integer read FPartId write FPartId;
end;
一个继承的类
TPartTwo = class(TPart)
private
FDesc: String;
public
property Desc: String read FDesc write FDesc;
end;
我有一个将对象加载到Tlistobject
的函数function LoadItems<T: class, constructor>(aID: Integer; aInstanceOwner: Boolean = True): TObjectList<T>;
我想将一些TListObect<TPartTwo>
传递给TListObject<TPart>
。这可能吗?有人可以帮我指出正确的方向吗?
function TPartAgent.GetBackOrderByPart(aPartID: Integer): TObjectList<TPart>;
begin
...
Result:= self.LoadItems<TPartTwo>(aPartID) ; //loaditems give a TObjectList of TPartTwo
...
end;