C# 对TPH实体使用Web API ODATA$expand=*
ODATAC# 对TPH实体使用Web API ODATA$expand=*,c#,asp.net-web-api,odata,tph,C#,Asp.net Web Api,Odata,Tph,ODATA$expand=*术语扩展实体的所有属性。但在TPH模式中,它仅扩展基类引用属性: 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 Employe
$expand=*
术语扩展实体的所有属性。但在TPH模式中,它仅扩展基类引用属性:
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 : Person
{
public Post Post{get;set;}
}
执行ODATA查询:/ODATA/Persons?$expand=*
仅扩展Place.BirthPlace
引用属性;不是Customer.Job
也不是Employee.Post
但是扩展单个实体的效果与预期一样好:/odata/Persons(411)?$expand=*
扩展地点.出生地
,或者客户.工作
或者员工.职位
基于实体的类型
如何扩展TPH场景中的所有引用实体