Webapi: Expand all not working on inherited entities properties

Created on 9 Aug 2017  路  4Comments  路  Source: OData/WebApi

The $expand=* term expands all properties of an entity. But in the TPH pattern, it expands only the base class reference properties:

public abstract class Person
{
     [Key]
     public int Id {get; set; }

     public Place BirthPlace { get; set;}
}

public class Customer : Person
{
  public Job Job{get;set;}
}

public class Employee
{
  public Post Post{get;set;}
}

Executing ODATA query: /odata/Persons?$expand=* only expands the Place BirthPlace reference property; not the Customer.Job nor Employee.Post

But expanding a single entity works well as expected: /odata/Persons(411)?$expand=* expands Place BirthPlace and either Customer.Job or Employee.Post based on the type of the entity

P2 bug

Most helpful comment

It has been a long time. Any updates on this issue?

All 4 comments

It has been a long time. Any updates on this issue?

Any updates ?

Same issue on my end. Attempting to expand fields only in the inherited subclasses results in a partial 200 response JSON and an error The EDM instance of type '<expanded class name here>' is missing the property '<a field name from the expanded class here>'.. Furthermore, the actual executed SQL doesn't perform a JOIN to retrieve the information in the first place.

Is TPH not supported?

Came across this comment in another issue and tried upgrading to .NET 5.0 preview3. This issue appears to be resolved now.

Was this page helpful?
0 / 5 - 0 ratings