[英]Naming Parent Entity Relations if multiple relations with a Table - Entity Data Model - ADO.Net
如果一个表与其他表有多个关系。 例如员工和约会表。 约会表有 2 个字段作为 Employee 表的外键。 1 个密钥用于约会,我们为添加该记录的员工保留其他密钥。
现在,在代码中,当我们通过 Appointment object 访问 Employee 时,它会提供像 Appointment.Employee 和 Appointment.Employee1 这样的引用
有没有办法可以将 Employee 和 Employee1 重命名为有意义的关系?
提前致谢,
您可以随意命名导航属性
public class Appointment
{
...other props
public int EmployeeId { get; set; }
public virtual Employee Employee { get; set; }
public int CreatedByEmployeeId { get; set; }
public virtual Employee CreatedByEmployee { get; set; }
}
因此,您可以这样称呼它:Appointment.Employee 或 Appointment.CreatedByEmployee
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.