我在下面的代码中收到PXDefault的发布错误

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

我已经检查了所有花括号和代码的语法,这是唯一发布的代码。我删除了所有其他内容

using PX.Objects;
using PX.Data;

namespace MaxQ.Products.RBRR
{
  public class ContractMaint_Extension : PXGraphExtension<ContractMaint>
  {
    #region Event Handlers

    protected virtual void XRBContrHdr_DestSiteID_CacheAttached(PXCache cache)
      {   
         [PXDefault(typeof(Search2<INSite.siteCD,
          InnerJoin<BAccount, On<BAccount.bAccountID, Equal<Current<XRBContrHdr.bAccountID>>>,
          InnerJoin<LocationExtAddress, On<LocationExtAddress.locationID, Equal<BAccount.defLocationID>>>>,
          Where<INSite.siteID, Equal<LocationExtAddress.cSiteID>>>), PersistingCheck = PXPersistingCheck.Nothing)]
      }

    #endregion
  }
}

我得到的错误是

\\ App_RuntimeCode \ ContractMaint.cs(13):错误CS1513:预期为]

\\ App_RuntimeCode \ ContractMaint.cs(18):错误CS1519:类,结构或接口成员声明中的无效令牌'}'

\\ App_RuntimeCode \ ContractMaint.cs(22):错误CS1022:类型或名称空间定义,或预期的文件结尾

\\ App_RuntimeCode \ ContractMaint.cs(13):错误CS1513:预期为]

c# acumatica
2个回答
0
投票

对于使用高速缓存附加的方法,属性是在方法上定义的,还需要为字段上的属性指定“覆盖”方法。因此,一个工作示例将是

[PXMergeAttributes(Method = MergeMethod.Append)]    
[PXDefault(typeof(Search2<INSite.siteCD,
      InnerJoin<BAccount, On<BAccount.bAccountID, Equal<Current<XRBContrHdr.bAccountID>>>,
      InnerJoin<LocationExtAddress, On<LocationExtAddress.locationID, Equal<BAccount.defLocationID>>>>,
      Where<INSite.siteID, Equal<LocationExtAddress.cSiteID>>>), PersistingCheck = PXPersistingCheck.Nothing)]
virtual void XRBContrHdr_DestSiteID_CacheAttached(PXCache cache) {}

This帮助文档将解释有关PXMergeAttributes属性的更多信息


0
投票

错误消息指向源代码中格式错误的块{}enter image description here

之所以会出现这种情况,是因为需要将属性放置在装饰方法的方法之前:

[PXDefault(…)]
protected virtual void XRBContrHdr_DestSiteID_CacheAttached(PXCache cache)
{
}

在您的代码中,属性被放置在方法定义中,这在C#中无效:

protected virtual void XRBContrHdr_DestSiteID_CacheAttached(PXCache cache)
{
   [PXDefault(…)]
}
© www.soinside.com 2019 - 2024. All rights reserved.