avatar image
Former Member

oData entity set selection with navigation

In the Northwind odata model there is an association/navigation between Suppliers and Products entity sets. To get all products of supplier '1' in SAPUI5 i can use the following:

oModel.read("/Suppliers(1)/Products");

But what if I have a collection of suppliers and want to select all products for these suppliers. Should I loop at oModel.read ? What about performance? E.g.

var suppliers ["1", "2", "3", "4"];
for (var i=0;i<suppliers.length;i++){
oModel.read("/Suppliers("+ suppliers[i] +")/Products")
}

Or should I create a filter with all the suppliers and do:

oModel.read("/Products");

Along with passing filters for the entity set?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 07, 2016 at 05:54 PM

    This is what you require

    http://services.odata.org/V4/Northwind/Northwind.svc/Suppliers?$filter=SupplierID eq 1 or SupplierID eq 2 or SupplierID eq 3 or SupplierID eq 4 or SupplierID eq 5&$expand=Products

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 06, 2016 at 11:23 PM

    There is an OData option $expand, your code could be like this

    oModel.read("/Suppliers?$expand=Products");

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content