所以,我的实体模型中有一个继承层次结构,如下所示:
class Member
{
public virtual Information Information { get; set; }
public long InformationId { get; set; }
//Other Props
}
class Staff : Member
{
}
class Guest : Member
{
}
class Information
{
public string Name { get; set; }
}
class StaffInformation : Information
{
public DateTime BirthDate { get; set; }
}
class GuestInformation : Information
{
public DateTime Expiry { get; set; }
}
鉴于此,我很难将会员信息转换为正确的孩子。例如,我想:
TextBoxFor(model => model.Staff.StaffInformation.BirthDate)
但我能做的是:
TextBoxFor(model => (Entities.StaffInformation)(model.Staff.Information).BirthDate)
我可以指定孩子的信息类型吗?一些类似于以下伪的东西:
class Staff : Member
{
public StaffInformation Information { get; set; }
}
class Guest : Member
{
public GuestInformation Information { get; set; }
}
有什么建议吗?