我想使用属性参数扩展 TMyQuery 类。 我想使用与使用 TADOQuery 相同的语法来调用 TMyQuery。 如何正确扩展我的课程?
/// new class
type TMyQuery = class (TFDQuery)
private
procedure SetParamByName(const Param: TParam);
public
/// here i fail !
property Parameters[const AName: string]: TParam Write SetParamByName;
end;
procedure TMyQuery.SetParamByName(const Param: TParam);
begin
// Params.ParamByName(AName). ??? ;
end;
/// code example
...
...
/// calling FFDQuery with same syntax like ADO Query
qryInsert.Parameters.ParamByName('ID').AsInteger := recordCount;
你可以尝试这样的:
TMyQuery = class (TFDQuery)
private
procedure SetParamByName(const AName: string; const Value: TParam);
public
/// ...
property Parameters[const AName: string]: TParam Write SetParamByName;
end;
在执行该程序时,请尝试以下操作:
procedure TMyQuery.SetParamByName(const AName: string; const Value: TParam);
begin
inherited ParamByName(AName).Value := Value.Value;
end;
这是您需要的吗?