【问题标题】:Bql Query With In Operator returning incorrect results使用 In 运算符返回错误结果的 Bql 查询
【发布时间】:2019-06-04 12:50:37
【问题描述】:

我正在使用 InvoiceEntryExt Graph 扩展,并添加了一个名为“Receipts”的 DAC,我已经用 IEnumerable 方法覆盖了它。

public PXSelect<POReceipt> Receipts;
public IEnumerable receipts()
{
   List<string> receiptNbrList = new List<string>(); 
   foreach(APTran tran in Base.Transactions.Select())
   {
      if(!string.IsNullOrEmpty(tran.ReceiptNbr) && !receiptNbrList.Contains(tran.ReceiptNbr))
      {
        receiptNbrList.Add(tran.ReceiptNbr);
      } 
   }

   object[] values = receiptNbrList.ToArray();       
   PXResultset<POReceipt> rcpts = PXSelect<POReceipt, Where<POReceipt.receiptNbr, In<Required<POReceipt.receiptNbr>>>>.Select(new PXGraph(), values);             
   return rcpts;
}

当查询执行时,我将多个收据编号传递到值数组中,但每次我只得到 1 个收据结果,当我知道事实应该有更多时。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    您传递值的方式不正确,如下面的代码

    object[] values = receiptNbrList.ToArray();       
    PXResultset<POReceipt> rcpts = PXSelect<POReceipt, Where<POReceipt.receiptNbr, In<Required<POReceipt.receiptNbr>>>>.Select(new PXGraph(), values);    
    

    将值作为 params object[] pars 传递,但该数组应包含与每个 Current/Optional/Required 对应的值。
    In运算符传递参数的正确方法如下:

    string[] values = receiptNbrList.ToArray();       
    PXResultset<POReceipt> rcpts = PXSelect<POReceipt, Where<POReceipt.receiptNbr, In<Required<POReceipt.receiptNbr>>>>.Select(new PXGraph(), new object[]{ values });
    

    您应该将一个对象数组传递给 Select 方法,并且该数组的第一个成员应该是与 In 运算符中的 Required 运算符相对应的字符串数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多