2013-03-28 54 views
0

當我通過客戶查詢在線查詢快速通關時,我似乎不斷收到重複項。下面是我的代碼,我想知道爲什麼我多次獲得相同的客戶。我正在使用分頁功能來避免超時。當從QBO向客戶詢問時,我得到重複客戶

 Dim tCust As New List(Of Intuit.Ipp.Data.Qbo.Customer) 

     Dim qcust As New CustomerQuery 
     qcust.IncludeJobs = False 
     qcust.LastUpdatedTime = FromDate 
     qcust.PageNumber = 1 
     qcust.ResultsPerPage = 10 

     Dim customers As IEnumerable(Of Intuit.Ipp.Data.Qbo.Customer) = qcust.ExecuteQuery(Of Customer)(GetServiceContext) 
     While customers.Count > 0 
      tCust.AddRange(customers) 
      customers = qcust.ExecuteQuery(Of Customer)(GetServiceContext) 
      qcust.PageNumber += 1 
     End While 

回答

2

您沒有在正確的位置遞增頁碼,因此您正在對PageNum = 1和ResultsPerPage = 10執行兩個請求。

頁碼應在循環中增加如下:

Dim tCust As New List(Of Intuit.Ipp.Data.Qbo.Customer)() 

Dim qcust As New CustomerQuery() 
qcust.IncludeJobs = False 
qcust.LastUpdatedTime = New DateTime(2013, 1, 1) 
qcust.PageNumber = 1 
qcust.ResultsPerPage = 10 

Dim customers As IEnumerable(Of Intuit.Ipp.Data.Qbo.Customer) = qcust.ExecuteQuery(Of Customer)(context) 
While customers.Any() 
    tCust.AddRange(customers) 
    If customers.Count() < qcust.ResultsPerPage Then Exit While 
    qcust.PageNumber += 1 
    customers = qcust.ExecuteQuery(Of Customer)(context) 
End While