on 02-20-2019 1:48 PM
Hi All,
Below are the tables that I'm trying to link/navigate through
Table 1 : mid.customer
Primary Key : customer_id
Table 2 : mid.product
Primary Key : product_id,id
Table 3 : mid.Item
Primary Key : id
Here the 3 tables are connected with the columns as below
1 ) purchased_product_id(table1) -> product_id(table 2)
2) id(table2) -> id(table 3)
So the output columns i need is customer_id(table 1), name(table 2) and type(table 3). I tried writing some xsodata associations to achieve this, but I was not able to extend beyond associations of two tables. Below is the code
"mid.customer" /* table 1*/
as "customer1" navigates ("customer_buy" as "purchase");
"mid.product" /* table 2*/
as "product1";
association "customer_buy"
principal "customer1"("purchased_product_id")
multiplicity "1"
dependent "product1"("product_id")
multiplicity "*";
How to extend the code so that I get the desired output columns? Please help.
If you really just wanna have an additional association from table 2 to table 3 then just add it For instance:
service {
"mid.customer" /* table 1*/
as "customer1" navigates ("customer_buy" as "purchase");
"mid.product" /* table 2*/
as "product1" navigates ("itemInfo" as "toItem");
"mid.Item" /* table 3*/
as "item";
association "customer_buy"
principal "customer1"("purchased_product_id")
multiplicity "1"
dependent "product1"("product_id)
multiplicity "*";
association "itemInfo"
principal "product1"("id")
multiplicity "1"
dependent "type" ("id")
multiplicity "1";
}
With that you are able to do a GET request on the customer1 entity getting the releated data from the product1 and item entity using an expand.
....xsodata/customer1?$format=json&$expand=purchase,purchase/toItem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.