【问题标题】:How to generate SQL with specific table columns using BQL如何使用 BQL 生成具有特定表列的 SQL
【发布时间】:2017-07-22 01:26:42
【问题描述】:

当我在 BQL 语法中加入两个 DAC 时,它会生成 SQL,从两个表中选择所有列。如果我想选择一个表的列以达到良好的执行计划怎么办?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    您可以尝试查看PXProjection,其中列被定义为投影类中的字段。 PXProjection 就像 Acumatica 中的 DAC 一样的 SQL 视图。只需在 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
    }
    

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      相关资源
      最近更新 更多