使用$ expand的OData查询,但根$ select为空

Ric*_*ber 3 odata

我在根元素上有一个具有多个NavigationProperties的OData服务。我想在查询中不从根返回任何结果,例如($top为了简洁起见,删除了的和)

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

可能会回来

{
    "value": [{
        "Friends": [{
                "FirstName": "Scott"
        }]
    }]
}
Run Code Online (Sandbox Code Playgroud)

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

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

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

Ric*_*ber 5

啊...找到了!

如果您有$expandNavigationProperty的,则可以将NavigationProperty名称用作$select,因此

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

产量*

{
    "value": [{
        "Friends": [{
            "FirstName": "Scott"
        }]
    }]
}
Run Code Online (Sandbox Code Playgroud)

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