是否可以使用$expand
但不返回对象集合,只返回对象的数量?
例如,在单个WebApi调用中获取帐户及其注释计数
我尝试了一些事情。
accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($count=true)
返回所有注释的所有字段但不计算任何内容。accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid&$count=true)
返回一个错误:“找到一个不平衡的括号表达式”。我认为这与$expand
中的&符号有关accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$expand=Account_Annotation($select=annotationid;$count=true)
它没有给出错误,但$count
指令似乎被忽略accounts(6CDEEB72-2AC8-E711-A825-000D3AE0A7F8)?$select=name&$count=Account_Annotation($select=annotationid)
的疯狂尝试返回“非有效计数”错误我猜这不是一个有效的组合,但我想我会发布在这里以防其他人成功实现这一点。
我得到了这个工作,但我不确定它是你正在寻找什么,它只有在扩展之前我把它计数时才有效:
api/data/v9.0/cmnt_salesexample?
$select=endcustomeraccountid&$count=true&$expand=endcustomerid($select=accountid)
输出:
{
"@odata.context": "https://xyz",
"@odata.count": 5000,
"value": [
{
"@odata.etag": "W/\"3560581422\"",
"endcustomerid": "54321"
},
{
"@odata.etag": "W/\"3510396844\"",
"endcustomerid": "12345"
},
...