Search code examples
odataodata-v4

oData navigation vs filtering


When using a navigation: http://services.odata.org/V4/Northwind/Northwind.svc/Suppliers(1)/Products or filtering: http://services.odata.org/V4/Northwind/Northwind.svc/Products?$filter=SupplierID eq 1

I will get exactly the same results so products belonging to the supplier "1". So when and why should I use navigation and when filtering?


Solution

  • Your example of fitering is indeed something that can be achieved easier by using navigation.

    Use navigation when you know the key of the element you are looking for (your first example) and use filtering when you want to get a subset of elements that match a certain criteria. E.g. get all records with a reorder level > 20:

    http://services.odata.org/V4/Northwind/Northwind.svc/Suppliers%281%29/Products?$filter=ReorderLevel gt 20