odata - 计算 Dynamics CRM Online web api (ODATA) 中的所有行

标签 odata dynamics-crm dynamics-crm-online dynamics-crm-365 dynamics-crm-webapi

是否可以计算给定实体中的所有行,绕过 5000 行限制并绕过页面大小限制?

我不想在一个请求中返回超过 5000 行,而只想返回给定实体中所有行的计数。

根据 Microsoft 的说法,您不能在请求 URI 中执行此操作:

The count value does not represent the total number of entities in the system. 

It is limited by the maximum number of entities that can be returned.

我试过这个:
GET [Organization URI]/api/data/v9.0/accounts/?$count=true

还有什么办法吗?

最佳答案

更新:

最新发布的 v9.1 具有直接实现此功能的功能 - RetrieveTotalRecordCount

————————————————————————————————

不幸的是,我们必须选择这条路线之一来根据限制内的预期结果识别记录数。

1.如果小于5000,使用这个: (你已经试过了)

GET [Organization URI]/api/data/v9.0/accounts/?$count=true

2. 50000以下,用这个:
GET [Organization URI]/api/data/v8.2/accounts?fetchXml=[URI-encoded FetchXML query]

超出限制会报错:AggregateQueryRecordLimit exceeded. Cannot perform this operation.
示例查询:
<fetch version="1.0" mapping="logical" aggregate="true">
  <entity name="account">
    <attribute name="accountid" aggregate="count" alias="count" />
  </entity>
</fetch>

使用 URI 进行浏览器地址栏测试:
[Organization URI]/api/data/v8.2/accounts?fetchXml=%3Cfetch%20version=%221.0%22%20mapping=%22logical%22%20aggregate=%22true%22%3E%3Centity%20name=%22account%22%3E%3Cattribute%20name=%22accountid%22%20aggregate=%22count%22%20alias=%22count%22%20/%3E%3C/entity%3E%3C/fetch%3E

The only way to get around this is to partition the dataset based on some property so that you get smaller subsets of records to aggregate individually.



Read more

3.最后的手段是迭代@odata.nextLink 并使用代码变量( code example to query the next page )计算每个页面中的记录

关于odata - 计算 Dynamics CRM Online web api (ODATA) 中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51543802/

相关文章:

javascript - 使用 Angular 提供程序构建 OData $filter URL

asp.net-web-api - 在 ASP.NET Web API OData 中返回子元素

javascript - 动态retrieveMultipleRecords异步问题

dynamics-crm - 何时指定 PagingInfo.PagingCookie 和 PagingInfo.PageNumber

dynamics-crm-2011 - Javascript 函数不会在 crm 2011 中触发更改事件

c# - Microsoft.AspNetCore.Odata 配置日期时间序列化以使用 Utc 或省略 Timezone

c# - OData Linq 到查询字符串

javascript - 在创建模式下对预填充的同一实体进行两次查找

email - 通过进程处理 "send email"步骤的可重用且稳健的模式

dynamics-crm - crm在线,添加组织