Creating an OData Service with an Entity Relationship
You will learn
The first example of this exercise was very simplistic because it only exposed one database table as a single entity. Often you need to also represent relationships between multiple entities. For example you might want to build an OData service which has both the Purchase Order Header and Items. For this you would build a 1:many relationship between the two entities.
Step 1: Create new OData service
Create an OData service called purchaseOrders.xsodata
as "POHeader" navigates ("Items" as "POItem");
Associations can be an excellent way to load child elements on demand; however there is also an option to expand the children details in place so that all levels can be retrieved with one request. Test the service again using the same steps as in the previous section of this exercise. This time add $expand=POItem to the end of the URL. You will then see that all the items are embedded within each header record (i.e., it is no longer deferred as in the previous test).