首页 > 解决方案 > 如何用泛型覆盖方法?

问题描述

我正在尝试覆盖 PIGenerator 图中的UpdateCommandByGenerationMethod方法。

在此处输入图像描述

Acumatica 给出了一个空白模板,如下所示:

public delegate BqlCommandWithParameters UpdateCommandByGenerationMethodDelegate(BqlCommandWithParameters cmd);
[PXOverride]
public BqlCommandWithParameters UpdateCommandByGenerationMethod(BqlCommandWithParameters cmd, UpdateCommandByGenerationMethodDelegate baseMethod)
{
  /* */
  return baseMethod(cmd);
}

这将发布没有错误的罚款。但是当我加载屏幕时。我收到一个错误:

Method PX.Objects.IN.PhysicalInventory.BqlCommandWithParameters UpdateCommandByGenerationMethodTSiteIdField,TInventoryIdField,TSubItemIdField,TLocationIdField 是一个通用的方法定义

说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息: System.ArgumentException: Method PX.Objects.IN.PhysicalInventory.BqlCommandWithParameters UpdateCommandByGenerationMethodTSiteIdField,TInventoryIdField,TSubItemIdField,TLocationIdField 是通用方法定义

Acumatica 中的实际方法签名如下:

protected virtual BqlCommandWithParameters UpdateCommandByGenerationMethod<TSiteIdField, TInventoryIdField, TSubItemIdField, TLocationIdField>(
BqlCommandWithParameters cmd)
    where TSiteIdField : IBqlOperand
    where TInventoryIdField : IBqlField
    where TSubItemIdField : IBqlField
    where TLocationIdField : IBqlField
{
    ...
}

那么如何修复委托方法的声明呢?

提前致谢。

标签: acumatica

解决方案


不幸的是,如果它使用泛型,则无法 PXOverride 方法


推荐阅读