我有两个实体:Employee
& Contract
。
在Contract
实体中,我有属性AddedByEmployee
& AssignedToEmployee
。
我想要一个类中的集合导航属性,Employee
但是如何在类中引用正确的键Contract
?
到目前为止,我有:
public class Employee
{
public int EmployeeID {get; set;}
public string Name {get; set;}
private readonly ObservableListSource<Contract> _Contracts = new ObservableListSource<Contract>();
public virtual ObservableListSource<Contract> Contracts { get { return _Contracts; }
}
public class Contract
{
public int ContractID {get; set;}
public string Name {get; set;}
public int AddedByEmployeeID {get; set;}
public int AssignedToEmployeeID {get; set;}
[ForeignKey("AddedByEmployeeID")]
public virtual Employee AddedByEmployee { get; set; }
[ForeignKey("AssignedToEmployeeID")]
public virtual Employee AssignedToEmployee { get; set; }
}
所以基本上:我如何让ObservableListSource<Contract>
知道它是AddedByEmployeeID
我想要映射到的?
谢谢