我很好奇是否可以通过包含对象映射中间表。
public class Subscriber : IEntity
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
private ChannelList _subscribedList { get; set; }
public int NumSubscribedChannels { get { return _subscribedList.Count(); } }
}
public class HelpChannel : IEntity
{
[Key]
public int Id { get; set; }
public string name { get; set; }
public string category { get; set; }
public int group { get; set; }
}
我需要一个订阅者表、频道表和一个中间表来将订阅者链接到他/她的频道。
是否可以将 ChannelList 对象中的列表映射到订阅者模型?
我认为这可能是不可能的,我只需要一个私有列表供 EF 映射。但我不确定 EF 是否会对私有变量执行此操作。会吗?
我希望这样做是因为如果它必须公开以维护封装。