[英]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.