OData Association and Navigation

light111Association and Navigation


Let’s keep things simple to understand.  To under stand Association and Navigation in oData, let’s work on simple FLIGHT Model data. 

Let’s display all the entries from the SCARR table and Now user wants to see all dependent records from SPFLI table based on Carrier ID(CARRID) which can be achieved through association and navigation.

Let’s build a oDATA project in Tx- SEGW.

12


We have to design entity types and entity sets for both SCARR and SPFLI structure.

345

Choose KEY.

6

One Entity Type and Entity Set is created.

7

Create one more entity type and entity set for SPLFI structure.

89

Choose few/all fields.

10

Define the key fields.

11

We are ready with 2 entity types and entity sets. Now we can set up a association between two.

12

Let’s create an association.

13

Provide a association name and the entity types. 

Principal Entity- Scarr and the target/dependent entity- Spfli.

Provide the cardinality:  1 to Many

And also provide the Navigation Property Name.

14

The below screen appears, now we have to maintain the match up fields.

15

For dependent entity, from F4 provide dependent property as Carrid.

16

Create association set, than links the entity sets. Choose Finish.

17


All we can see below, the created association, association sets, referential constraints.

18

Time to generate the run time artifacts.19

Yes to continue.

20

All generated successfully.21

Now we have to implement the GET_ENTITY & GET_ENTITYSET method for both entity types.

2223

SCARR- GET_ENTITY method

24


25

SCARR- GET_ENTITYSET method

26


SPFLI- GET_ENTITY method

2728


29

SPFLI- GET_ENTITYSET method

30


Now we have to register the SERVICE.

31

Tx- /IWFND/MAINT_SERVICE

Choose Add Service.

32

Search and add.

3334


Call browser to test.

35


In addition to the basics, it shows the navigation and association properties.

36373839


41


Let’s query entity set: ScarrSet ( in json format).

It shows all records from SCARR table and along with the URL for the NAVIGATION property for each Carrid.

4042


In JSON format view, you can directly click on the navigation view for each Carrid and that will show the dependent records from SPFLI. 

For carrid = ‘LH’, we have 4 dependent records.

44


let’s query for the Scarr Entity – Carrid(‘JL’) in xml format.

Its like below and shows the href link for the Navigation.

46


Let’s view it in JSON format.

48


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s