0

当我通过客户查询在线查询快速手册时,我似乎不断收到重复。下面是我的代码,我想知道为什么我会多次获得同一个客户。我正在使用分页功能来避免超时。

        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
4

1 回答 1

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
于 2013-03-29T13:21:36.147 回答