Acumatica 使用多个联接和where子句搜索2

Acumatica 使用多个联接和where子句搜索2,acumatica,Acumatica,我是Acumatica的新手,代码中有语法错误,似乎找不到。 下面是错误和代码。 正在生成目录“\WebSiteValidationDomain\App\u RuntimeCode\” \App_RuntimeCode\ContractMaint.cs(13):错误CS0305:使用泛型类型“InnerJoin”需要2个类型参数 [PXMergeAttributes(Method = MergeMethod.Merge)] [PXDefault(typeof(Searc

我是Acumatica的新手,代码中有语法错误,似乎找不到。 下面是错误和代码。 正在生成目录“\WebSiteValidationDomain\App\u RuntimeCode\”

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


      [PXMergeAttributes(Method = MergeMethod.Merge)]
      [PXDefault(typeof(Search2<PX.Objects.CR.Location.cSiteID,
       InnerJoin<PX.Objects.CR.BAccount, On<PX.Objects.CR.BAccount.acctCD, Equal<Current<XRBContrHdr.customerID>>>,
       InnerJoin<PX.Objects.AR.Customer, On<PX.Objects.AR.Customer.bAccountID, Equal<PX.Objects.CR.BAccount.bAccountID>>>,
       InnerJoin<PX.Objects.CR.Location, On<PX.Objects.CR.Location.bAccountID, Equal<PX.Objects.AR.Customer.bAccountID>>>>,
        Where <PX.Objects.CR.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)
    {

    }```


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


      [PXMergeAttributes(Method = MergeMethod.Merge)]
      [PXDefault(typeof(Search2<PX.Objects.CR.Location.cSiteID,
       InnerJoin<PX.Objects.CR.BAccount, On<PX.Objects.CR.BAccount.acctCD, Equal<Current<XRBContrHdr.customerID>>>,
       InnerJoin<PX.Objects.AR.Customer, On<PX.Objects.AR.Customer.bAccountID, Equal<PX.Objects.CR.BAccount.bAccountID>>>,
       InnerJoin<PX.Objects.CR.Location, On<PX.Objects.CR.Location.bAccountID, Equal<PX.Objects.AR.Customer.bAccountID>>>>,
        Where <PX.Objects.CR.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)
    {

    }```



[PXMergeAttributes(Method=MergeMethod.Merge)]
[PXDefault(typeof(Search2),PersistingCheck=PXPersistingCheck.Nothing)]
[PXFormula(typeof(默认))]
受保护的虚拟无效XRBConthrdr_DestSiteID_CacheAttached(PXCache缓存)
{
}```

以下版本的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)
        {
        }
使用PX.Objects.CR;
使用PX.Objects.AR;
...
[PXMergeAttributes(Method=MergeMethod.Merge)]
[PXDefault(typeof(Search2),PersistingCheck=PXPersistingCheck.Nothing)]
[PXFormula(typeof(默认))]
受保护的虚拟无效XRBConthrdr_DestSiteID_CacheAttached(PXCache缓存)
{
}
如果可能的话,我建议您首先在VisualStudio中创建这些查询,因为它在这个过程中非常有帮助

关于查询:

  • 您的第一个连接是使用Baccount.accctd:理想情况下,您应该将整数值存储在XRBContrHdr.customerID中,而不是CD值。你会在所有acumatica页面中注意到这种模式。通过此更改,将使用baccount.bAccountID完成连接
  • 您在第一个联接的子句中使用了Current:如果您使用Current作为筛选条件,我建议将其移动到Where部分 2.2:BAccount和Location之间的第一个联接中的ON子句似乎缺失

  • 无需在最后一次连接中再次添加位置。那一刻你已经有了
  • 请尝试以下替代版本:

    [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)]
    
    [PXDefault(typeof(Search2),PersistingCheck=PXPersistingCheck.Nothing)]
    

    请注意,这两个版本都将生成多重性。BAccount/Customer和Location之间存在一对多的关系

    @TRex您是否能够测试建议的答案?