Search code examples
asp.net-web-apiodata

Querying nested navigation properties in odata


I would like to expand all navigation properties in my odata service...

public class Order
{
     Product Product {get;set;}
}

public class Product
{
     Category Category {get;set;}
}

public class Category
{
     string Name {get;set;}
}

How do I show all of these navigation properties? This is what I have

/odata/Orders?$expand=Product

how do I also show the category??


Solution

  • Try this:

    /odata/Orders?$expand=Product($expand=Category)
    

    You can check with odata sample service:

    http://services.odata.org/V4/(S(snopayoxlhy2hc4bpjgatvfj))/TripPinServiceRW/People?$expand=Friends($expand=Photo)