2016-01-08 36 views
0

我想知道在通過Web Service API從Acumatica檢索數據時是否有添加「Order By」子句的方法?「排序依據」當從Acumatica Web服務API中檢索

IN202500Content IN202500 = oScreen.IN202500GetSchema(); 
 
oScreen.IN202500Clear(); 
 

 
Command[] oCmd = new Command[] {IN202500.StockItemSummary.ServiceCommands.EveryInventoryID, 
 
           IN202500.StockItemSummary.InventoryID, 
 
           IN202500.StockItemSummary.Description, 
 
           IN202500.StockItemSummary.ItemStatus, 
 
           IN202500.GeneralSettingsItemDefaults.ItemClass, 
 
           IN202500.GeneralSettingsItemDefaults.LotSerialClass, 
 
           IN202500.PriceCostInfoPriceManagement.DefaultPrice, 
 
           }; 
 
       
 
Filter[] oFilter = new Filter[] {new Filter 
 
           { 
 
            Field = new Field {ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, 
 
                 FieldName = "LastModifiedDateTime"}, 
 
                 Condition = FilterCondition.GreaterOrEqual, 
 
                 Value = SyncDate 
 
           } 
 
           }; 
 

 
String[][] sReturn = oScreen.IN202500Export(oCmd, oFilter, iMaxRecords, true, false);

我想通過DefaultPrice例如對結果進行排序,這樣我可以(在這種情況下使用iMaxRecords = 200)檢索我的列表中的前200個最昂貴的物品

我還沒有看到任何允許我進行排序的參數。

回答

0

我就遇到了這個當我開發了一個循環分配系統和簡短的回答是使用Acumatica API,你不能做你必須做它的API之外結果的排序(此信息來自一個朋友來到密切綁定到Acumatica產品)。

我想出了兩個選項:

  1. 查詢您的數據庫直接...總有一些理由不這樣做,但它比從API拉動的結果要快得多,並允許你繞過BQL Acumatica使用並編寫一條SQL語句,它完全符合您希望提供比Acumatica發送的參差不齊的數組更容易操作的結果。
  2. 您可以使用一些Linq並構建第二個數組[] [],按價格排序,然後將其修剪到前200(您首先需要Acumatica的所有結果)。

    // This is rough but should get you there. 
    string[][] MaxPriceList = sReturn.OrderBy(innerArray => 
        { 
         if() // This is a test to make sure the element is not null 
         { 
          decimal price; 
          if (//test decimal is not null)) 
           return price; 
         } 
    
         return price.MaxValue; 
        }).Take(200).ToArray(); //Take 200 is a shot but might work 
    
+0

我還沒有前測試這一個,但對於頂部200 'TOP200 = MaxPriceList.Take(200);' –

相關問題