Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies To:# OData WebApi v7 for aspnet webapi supported
OData AspNet WebApi V7# OData Webapi for Webapi supported
OData AspNet WebApi V6
In OData WebApi 5.7, we can put AutoExpand attribute on navigation property to make it automatically expand without expand query option, or can put this attribute on class to make all Navigation Property on this class automatically expand.
Model
public class Product
{
public int Id { get; set; }
[AutoExpand]
public Category Category { get; set; }
}
public class Category
{
public int Id { get; set; }
[AutoExpand]
public Customer Customer{ get; set; }
}
Result
If you call return Product in response, Category will automatically expand and Customer will expand too. It works the same if you put [AutoExpand]on Class if you have more navigation properties to expand.