TFDQuery 和 TADOQuery 具有相同的语法

问题描述 投票:0回答:1

我想使用属性参数扩展 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;
delphi ado firedac
1个回答
0
投票

你可以尝试这样的:

  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;

这是您需要的吗?

© www.soinside.com 2019 - 2024. All rights reserved.