0
我正在使用CodeFirst作爲我的開發。對於我的實體中的所有模型類,我有一個名爲CommonFields的基類如何在實體中設置兩個字段之間的一個方向關係(在同一個表中或不同的實體)
public class CommonFields
{
public int Status { get; set; }
public DateTime CreatedOn { get; set; }
public int CreaedBy { get; set; }
public DateTime ModifiedOn { get; set; }
public int ModifiedBy { get; set; }
}
而且,例如,我有兩個類,如
public class Employee : CommonFields
{
public int Id { get; set; }
public string Name { get; set; }
//Other properties
}
public class User : CommonFields
{
public int Id { get; set; }
public string Name { get; set; }
//Other properties
}
如何設置對應關係從CreatedBy & ModifiedBy到用戶表。我只需要一個方向映射。
我需要獲取用戶信息,當我寫objEmployee.CreatedUser
感謝。