首页 > 解决方案 > 计数从 Dynamics 365 Web API 中的 $extend 返回的记录

问题描述

基本上,我有这样的事情:

https://company.crm.dynamics.com/api/data/v9.0/accounts?$select=accountid,accountnumber,name&$expand=crm_productbuyer($select=name)

我希望能够只计算返回的记录数,$expand而不是在 C# 中对其进行反序列化并对其进行计数。少一件事需要迭代。

这对我的情况不起作用:

API $expand 和 &count

编辑:

这里有很多事情表明这是不可行的:

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/retrieve-entity-using-web-api#retrieve-related-entities-for-an-entity-by-expanding-导航属性

您不能使用 /$ref 或 /$count 路径段仅返回相关实体的 URI 或相关实体的数量。


这是 OData 版本 4.0 第 1 部分的“11.2.4.2.1 扩展选项”部分中描述的系统查询选项的子集:协议加勘误表 02。选项 $skip、$count、$search、$expand 和 $levels Web API 不支持。

除非其他人插话来证明,否则会将其标记为答案。

标签: microsoft-dynamicsdynamics-365dynamics-crm-webapi

解决方案


听起来不可行:

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/retrieve-entity-using-web-api#retrieve-related-entities-for-an-entity-by-expanding-导航属性

您不能使用 /$ref 或 /$count 路径段仅返回相关实体的 URI 或相关实体的数量。


这是 OData 版本 4.0 第 1 部分的“11.2.4.2.1 扩展选项”部分中描述的系统查询选项的子集:协议加勘误表 02。选项 $skip、$count、$search、$expand 和 $levels Web API 不支持。


推荐阅读