Consider I have this OData expression:
http://services.odata.org/northwind/northwind.svc/Categories?
$expand=Products/Category
It will correctly expand the Products.Category
.
Now I want to expand another property too. For example 'Products.Supplier`.
I've tried duplicating the $expand
usage:
http://services.odata.org/northwind/northwind.svc/Categories?
$expand=Products/Category
&$expand=Products/Supplier
but it failed returning this error:
Query parameter '$expand' is specified, but it should be specified exactly once.
The $value option is used to get individual properties of an Entity. There are two ways to get individual properties from an entity. We can get the response in either OData format or get the raw value of the property. We need to add method to the controller named GetProperty here property is a name of the property.
The $select option specifies a subset of properties to include in the response body. For example, to get only the name and price of each product, use the following query: Console Copy. GET http://localhost/odata/Products?$select=Price,Name.
The $filter system query option allows clients to filter the set of resources that are addressed by a request URL. $filter specifies conditions that MUST be met by a resource for it to be returned in the set of matching resources. The semantics of $filter are covered in the OData:Core document.
According to OData ABNF, expand syntax should be:
expand = '$expand' EQ expandItem *( COMMA expandItem )
Which amounts to:
$expand=expandItem1,expandItem2,expandItem3,...
So please try:
http://services.odata.org/northwind/northwind.svc/Categories?$expand=Products/Category,Products/Supplier
For more information, see:
http://www.odata.org/documentation/odata-version-2-0/uri-conventions/#ExpandSystemQueryOption
You can also try this syntax for expanding multiple levels:
$expand=Products($expand=Category),...
This works well with MS OData implementation in WebAPI.
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