我正在使用 this 方法在 Web API 中使用 Fetch XML 进行分页。
当我们使用简单的获取时,Web API 工作得很好,如果有更多记录,它会返回分页 cookie 和结果,但是当我们使用复杂的(有链接实体的情况)获取 XML 时,它会返回分页 cookie 但为空,例如:
<b><cookie pagenumber="2" pagingcookie="" istracking="False" /></b>
在这里你可以看到我们在 pagingcookie 中什么都没有。
获取用于查询的XML:
<fetch mapping="logical" version="1.0" output-format="xml-platform" count="10" page="1" >
<entity name="invoicedetail" >
<attribute name="invoicedetailid" />
<attribute name="uomid" />
<attribute name="quantity" />
<attribute name="manualdiscountamount" />
<attribute name="priceperunit" />
<attribute name="extendedamount" />
<filter>
<condition entityname="invoice" attribute="customerid" operator="eq" value="{5A8F8B46-2443-E511-80E3-3863BB351E10}" />
</filter>
<link-entity name="invoice" from="invoiceid" to="invoiceid" >
<attribute name="invoiceid" />
<attribute name="invoicenumber" />
<attribute name="description" />
<attribute name="totalamount" />
<order attribute="ss_postingdate" descending="true" />
</link-entity>
</entity>
</fetch>
如果我们删除链接实体,它就会开始在响应中提供准确的分页 cookie,可以使用
@Microsoft.Dynamics.CRM.fetchxmlpagingcookie
获得。
复杂场景下有没有办法获取准确的分页cookie?
我以前在标准组织服务中见过这种情况发生。我建议只进行分页而不使用分页 cookie - 这解决了我在组织服务中的问题。
例如
<fetch mapping="logical" page="1" count="50">