BQL查询没有给出我期望的结果

时间:2017-08-02 19:48:31

标签: acumatica

我有一个由几个左连接组成的BQL结果集,其中一个表(ARCstRptControl)通过继承原始DAC在'别名'下多次连接。代码如下所示:

public class ARInv : PXGraph<ARInv, ARInvoice>
{
    [Serializable]
    public class ARCstRptControl1 : ARCstRptControl { }
    [Serializable]
    public class ARCstRptControl2 : ARCstRptControl { }

    foreach (PXResult<ARTran
                      ,PMTran
                      ,ARCstRptControl
                      ,ARCstRptControl1
                      ,PMTask
                      ,Account
                      ,ARCstRptControl2> thistran in PXSelectJoin<ARTran,
                                                            LeftJoin<PMTran,
                                                                On<ARTran.pMTranID, Equal<PMTran.tranID>>,
                                                            LeftJoin<ARCstRptControl,
                                                                On<PMTran.origAccountGroupID, Equal<ARCstRptControl.accountID>>,
                                                            LeftJoin<ARCstRptControl1,
                                                                On<PMTran.accountGroupID, Equal<ARCstRptControl1.accountID>>,
                                                            LeftJoin<PMTask,
                                                                On<PMTask.projectID, Equal<PMTran.projectID>,
                                                                And<PMTask.taskID,Equal<PMTran.taskID>>>,
                                                            LeftJoin<Account,
                                                                On<ARTran.accountID, Equal<Account.accountID>>,
                                                            LeftJoin<ARCstRptControl2,
                                                                On<Account.accountGroupID, Equal<ARCstRptControl2.accountID>>>>>>>>,
                                                Where<ARTran.tranType, Equal<Current<ARInvoice.docType>>, 
                                                And<ARTran.refNbr, Equal<Current<ARInvoice.refNbr>>>>>.Select(this))
        {
            ARTran artran = (ARTran)thistran;
            PMTran pmtran = (PMTran)thistran;
            ARCstRptControl srcgrp = (ARCstRptControl)thistran;
            ARCstRptControl1 destgrp = (ARCstRptControl1)thistran;
            PMTask pmtask = (PMTask)thistran;
            Account account = (Account)thistran; 
            ARCstRptControl2 destgrp2 = (ARCstRptControl2)thistran;

除ARCstRptControl2外,所有表/ DAC变量都具有预期结果。我已经将整个查询移动到SQL Server中,它给了我想要的结果,包括ARCstRptControl2 - 但我必须在BQL中加入这里的连接错误。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

由于我使用了别名DAC(ARCstRptControl1和2),并且由于我使用了这些别名DAC中的两个字段,因此我需要使用那些字段(以及任何其他可用的字段)在DAC声明中声明的别名如下(即,我在联接中使用accountID和columnID):

[Serializable]
public class ARCstRptControl1 : ARCstRptControl
{
    public abstract new class accountID : IBqlField { }
    public abstract new class columnID : IBqlField { }
}