skip to main content
Querying with OData Version 4 : Formulating queries with OData Version 4 : Navigating relationships : $expand query parameter
  

Try Now
$expand query parameter
The examples in this topic use the following table structure:
Customer ---> Order ---> OrderItem
|
---> Contact
The $expand system query parameter allows the related information to be embedded in the response of the parent or child entity. For example, you can obtain a list of customers with a list of all of their orders by issuing the query:
https://<myserver>:<port>/api/odata4/OracleDS/Customers?$expand=Orders
Each customer entity in the response contains the list of order entities belonging to that customer embedded in the customer entity. Multiple tables can be expanded. The following query returns the list of customer entities; embedded in each customer entity is the list of their orders and the list of contacts for that customer.
https://<myserver>:<port>/api/odata/OracleDS/Customers?$expand=Orders, Contacts
Hybrid Data Pipeline currently only allows expanding to one level deep. For example, the following multi-level query, which attempts to expand orders and order items for a customer, is not currently supported:
https://<myserver>:<port>/api/odata4/OracleDS/Customers?$expand=Orders/OrderItems
For OData 4 users, the results of the $expand query parameter can be refined by using $select, *, $filter, and $top system query options. For example, the following query returns the entity Price in addition to the entities related to Orders.
https://<myserver>:<port>/api/odata4/OracleDS/Customers?$expand=Orders($select=Price)