2017-07-21 81 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 
}