Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OData V4 more than one option in $expand

Tags:

odata

in OData V4 inside an $expand query you can nest as an option:

1)$expand

http://services.odata.org/V4/OData/OData.svc/Categories?$expand=Products($expand=ProductDetail)

2)$levels

Entities($expand=ChildItems($level=x)) where ChildItem is the same type of Entity

3)$select

http://services.odata.org/V4/OData/OData.svc/Categories?$expand=Products($select=Price)&$select=Name,Products

I would like to expand ProductDetail like this but of course it does not work

http://services.odata.org/V4/OData/OData.svc/Categories?$expand=Products($expand=ProductDetail&$select=Price,ProductDetail)&$select=Name,Products

This call gets

Query parameter '$select' is specified, but it should be specified exactly once

so you would think that you can $select only on the main entity but case #3 works perfectly.

I know that I could rewrite my query to achieve my objectives but I would like to know if this is possible.

Thanks, Alessandro

like image 629
ing.alfano Avatar asked Feb 22 '15 19:02

ing.alfano


1 Answers

The key is the separator. You have to separate each option with ";". I found the answer here

Case 3 becomes

http://services.odata.org/V4/OData/OData.svc/Categories?$expand=Products($select=Price,ProductDetail;$expand=ProductDetail)&$select=Name,Products

like image 152
ing.alfano Avatar answered Jan 03 '23 19:01

ing.alfano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!