是否可以基于特定列值进行外键映射。
我有以下实体。
public class Controller
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public virtual List<ControllerDevice> ActiveDevices { get; set; }
public virtual List<ControllerDevice> TamperedDevices { get; set; }
public virtual List<ControllerDevice> IgnoredDevices { get; set; }
}
public class ControllerDevice
{
public int Id { get; set; }
public DeviceStatus Status { get; set; }
public int ControllerId { get; set; }
public int NetworkDeviceId { get; set; }
public virtual Controller Controller { get; set; }
public virtual NetowkDevice NetowkDevice { get; set; }
}
public class NetowkDevice
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
}
public enum DeviceStatus
{
Active,
Tampered,
Ignored
}
是否可以基于和列表自动填充ActiveDevices
,或者我必须为每个列表创建三个不同的表。IE和. _TamperedDevices
IngoredDevices
ControllerDevice
DeviceStatus
ActiveControllerDevice
TamperedControllerDevices
IgnoredControllerDevices
如果您需要进一步解释,请告诉我。