I've got an OData service with multiple NavigationProperties on a root element. I'd like to perform a query where I don't return any results from the root, e.g. ($top
's and metadata removed for brevity)
http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=FirstName)&$select=null
could return
{
"value": [{
"Friends": [{
"FirstName": "Scott"
}]
}]
}
at present, I'm having to specify at least one column in the root-level $select
, otherwise all the columns at the root level get retrieved
(i.e. http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=FirstName)&$select=FirstName )
Is it possible to somehow specify an empty $select list? I can't see an obvious way in the ABNF.
ah... found it!
If you have an $expand
for a NavigationProperty, you can use the NavigationProperty name as the $select
, so
http://services.odata.org/V4/TripPinServiceRW/People?$expand=Friends($select=FirstName)&$select=Friends
yields*
{
"value": [{
"Friends": [{
"FirstName": "Scott"
}]
}]
}
* $top and metadata removed for clarity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With