如果返回的记录数少于5000,将失败吗?

时间:2019-02-02 00:53:40

标签: c# crm dynamics-crm-online dynamics-crm-2016 dynamics-365

我对编写的QueryExpression有多重请求。在某些情况下,五千多返回的记录,而在其他国家则返回小于5000条记录。我担心如果计数少于5000,将失败。这是真的吗?!

 QueryExpression queryService = conversionResponse.Query;
                int pageNumber = 1;
                RetrieveMultipleRequest multiRequest;
                RetrieveMultipleResponse multiResponse = new RetrieveMultipleResponse();

                do
                {
                    queryService.PageInfo.Count = 5000;
                    queryService.PageInfo.PagingCookie = (pageNumber == 1) ? null : multiResponse.EntityCollection.PagingCookie;
                    queryService.PageInfo.PageNumber = pageNumber++;

                    multiRequest = new RetrieveMultipleRequest
                    {
                        Query = queryService
                    };
                    multiResponse = (RetrieveMultipleResponse)service.Execute(multiRequest);

                    Allergies.Entities.AddRange(multiResponse.EntityCollection.Entities);
                } while (multiResponse.EntityCollection.MoreRecords);

1 个答案:

答案 0 :(得分:1)

在两种情况下都应该没问题。

这里有一个类似MSDN的例子。 Sample: Use QueryExpression with a paging cookie.