2017-07-21 85 views
0

特定的表列SQL当我BQL连接两个DAC的语法生成SQL将选择所有从两个表中的列。如果我想选择一个表的列以实现良好的执行计划,该怎么办?如何生成使用BQL

回答

0

你可以尝试寻找到PXProjection,其中列被定义为投影类中的字段。 PXProjection与Acumatica中的DAC相似。只要搜索的Acumatica源PXProjection,你应该找到很多例子。需要注意的是在类中你需要设置BqlField每个“列”这样的过程中知道哪些table.field您的投影字段映射到。

快速加入下面PXProjection。在这个例子中,DAC中只有1列,它映射到APRegister.docType

[PXProjection(typeof(Select2<APRegister, 
     InnerJoin<APInvoice, On<APInvoice.docType, Equal<APRegister.docType>, 
      And<APInvoice.refNbr, Equal<APRegister.refNbr>>>, 
     InnerJoin<APPayment, On<APPayment.docType, Equal<APRegister.docType>, 
      And<APPayment.refNbr, Equal<APRegister.refNbr>>>>>, 
     Where<APRegister.docType, Equal<APDocType.quickCheck>, 
      Or<APRegister.docType, Equal<APDocType.voidQuickCheck>>>>), Persistent = true)] 
[Serializable] 
public partial class APQuickCheck : APRegister 
{ 
    #region DocType 
    public new abstract class docType : PX.Data.IBqlField 
    { 
    } 
    [PXDBString(3, IsKey = true, IsFixed = true, BqlField = typeof(APRegister.docType))] 
    [PXDefault(APDocType.QuickCheck)] 
    [APQuickCheckType.List()] 
    [PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = false)] 
    [PXFieldDescription] 
    public override String DocType 
    { 
     get 
     { 
      return this._DocType; 
     } 
     set 
     { 
      this._DocType = value; 
     } 
    } 
    #endregion 
}