The $expand option in the query filter is used to request entities associated with the last segment of a request. This is often used to ensure that entities can be materialized with their relationships wired together and to reduce the number of roundtrips to the server.
For example, if
http://www.example.com/service.svc/Customers returns all customers, then
http://www.example.com/service.svc/Customers?$expand=Orders could be used to return all customers with all their Orders, assuming customers have an Orders collection.
You can use request multiple references and collections to be exapnded. One gotcha about the $expand syntax is that there is a different syntax for “drilling” through references: the forward slash is used to indicate drilling in, while a comma is used to separate the parallel expansion paths.
Here are some examples that will hopefully clarify this (omitting the path to the service).
/Customers?$expand=Orders. Returns customers and the orders of the customers.
/Customers?$expand=Orders,Preferences. Returns customers and the preferences of the customers.
/Customers?$expand=Orders,Orders/OrderDetails,Preferences. Returns customers, the orders of the customers, the order details of the orders of the customers, and the preferences of the customers.
/Customers?$expand=Orders/OrderDetails,Preferences. Same as the last one – when you go deep, all the parents are implied, so Orders/OrderDetailsOrders.
/Customers?$expand=Orders/OrderDetails,Orders/ShippingInfo. Returns customers, the orders of the customers, the order details of the orders of the customers, and the shipping informatio of the orders of the customers. Note that the ‘,’ is used to separate paths starting from the last segment (Customers), so if you want to expand properties in parallel from a deeper entity, you need to specify the path again, as in this example.
Hope this was helpful – please post comments if you have further questions!