具有多个联接和where子句的Search2

时间:2020-03-18 22:10:32

标签: acumatica

我是Acumatica的新手,我的代码中有语法错误,似乎找不到它们。 这里是错误和代码。 构建目录“ \ WebSiteValidationDomain \ App_RuntimeCode \”。

\ App_RuntimeCode \ ContractMaint.cs(13):错误CS0305:使用通用类型“ InnerJoin”需要2个类型参数

\ App_RuntimeCode \ ContractMaint.cs(13):错误CS0305:使用通用类型“ InnerJoin”需要2个类型参数

npm i -g degit

1 个答案:

答案 0 :(得分:1)

以下版本的BQL正常工作:

我通过在命名空间顶部添加PX.Objects.xx库简化了对象

using PX.Objects.CR;
using PX.Objects.AR;

...
        [PXMergeAttributes(Method = MergeMethod.Merge)]
        [PXDefault(typeof(Search2<Location.cSiteID,
             InnerJoin<BAccount, 
                On<BAccount.acctCD, Equal<Current<XRBContrHdr.customerID>>>,
            InnerJoin<Customer, 
                On<Customer.bAccountID, Equal<BAccount.bAccountID>>,
             InnerJoin<Location, 
                On<Location.bAccountID, Equal<Customer.bAccountID>>>>>,
        Where<BAccount.acctCD, Equal<Current<XRBContrHdr.customerID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]
        [PXFormula(typeof(Default<PX.Objects.CR.Location.cSiteID>))]
        protected virtual void XRBContrHdr_DestSiteID_CacheAttached(PXCache cache)
        {
        }

我建议-如果可能的话-您应该首先在Visual Studio中创建这些查询,因为它在此过程中会极大地帮助您。

关于查询:

  1. 您的第一个联接使用 Baccount.AcctCD :理想情况下,您应该将整数值而不是CD值存储在XRBContrHdr.customerID中。您将在所有acumatica页面中注意到此模式。进行此更改后,将使用baccount.bAccountID
  2. 完成连接
  3. 您在第一个联接的子句中使用 Current <> :如果使用Current作为过滤条件,我建议将其移至位置部分。

2.2:BAccount和Location之间的第一次联接中的ON子句似乎丢失了

  1. 无需在上一个“加入”中再次添加位置。此时您已经拥有它。

尝试以下替代版本:

[PXDefault(typeof(Search2<Location.cSiteID,
         InnerJoin<BAccount, 
             On<BAccount.bAccountID, Equal<Location.bAccountID>>,
        InnerJoin<Customer, 
            On<Customer.bAccountID, Equal<BAccount.bAccountID>>>>,
         Where<BAccount.bAccountID, Equal<Current<XRBContrHdr.customerID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]

请注意,两个版本都会产生多重性。 BAccount /客户与位置之间存在一对多的关系