OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
857 stars 473 forks source link

Expand all not working on inherited entities properties #1045

Open khodaie opened 7 years ago

khodaie commented 7 years ago

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

rahul7720 commented 5 years ago

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

SenyaMur commented 4 years ago

Any updates ?

davidyee commented 4 years ago

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?

davidyee commented 4 years ago

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