具有$expand但根$select为空的 OData 查询



>我有一个在根元素上具有多个导航属性的 OData 服务。我想执行一个查询,其中我不从根返回任何结果,例如(为简洁起见,删除了$top和元数据(

http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=名字(&$select=

可以返回

{
"value": [{
"Friends": [{
"FirstName": "Scott"
}]
}]
}

目前,我必须在根级别$select中至少指定一列,否则将检索根级别的所有

(即 http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=名字(&$select=名字 )

是否可以以某种方式指定一个空的$select列表?我在 ABNF 中看不到明显的方式。

啊...找到了!

如果您有导航属性的$expand,则可以使用导航属性名称作为$select,因此

http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=FirstName)&$select=Friends

收益 率*

{
"value": [{
"Friends": [{
"FirstName": "Scott"
}]
}]
}

* 为清楚起见,删除了$top和元数据

最新更新