解决此问题的正确方法是什么:假设我有一个对象表:
public class Object
{
public Guid Id { get; set; }
public ControlType Type { get; set; }
public Guid ControlId { get; set; }
public IControl Control { get; set; }
}
IControl 是一个由 10 个不同的控制对象实现的接口。它们的类型由 ControlType 枚举描述。我想将它们存储在不同的表中,并且在查询我的对象时,我希望我的对象根据其 Id 从 Control 特定表中作为 IControl Control 包含在内。
我知道我可以使用 TPH 继承,但我的控制表会很大,有很多空列,因为控件有很多不同的属性,具体取决于它们的类型。