当我通过客户查询在线查询quickbooks时,我似乎不断重复。下面是我的代码,我想知道为什么我多次得到同一个客户。我正在使用分页功能来避免超时。
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
答案 0 :(得分: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