在 Castle Activerecord 中(在 NHibernate 之上),是否可以全局使用类表继承,并在部分继承树上使用单表继承?我想做类似的事情
/// <summary>
/// Base class for models
/// </summary>
[ActiveRecord("model"), JoinedBase]
public abstract class Model: ActiveRecordBase
{
/// <summary>
/// Primary Key
/// </summary>
[PrimaryKey(PrimaryKeyType.UuidHex, "ROWID", Params = "format=D,separator=-")]
public virtual string Id { get; set; }
[Property("name")]
public string Name { get; set; }
[Property("description")]
public string Description{ get; set; }
}
/// <summary>
/// A container
/// </summary>
[ActiveRecord("container")]
public class Container : Model
{
/// <summary>
/// Gets the container id
/// </summary>
[JoinedKey("container_id")]
public override string Id
{
get { return base.Id; }
set { base.Id = value; }
}
}
/// <summary>
/// A glass
/// </summary>
[ActiveRecord("container",
DiscriminatorColumn = "container_type",
DiscriminatorValue = "1"
)]
public class Glass : Container
{
}
这样所有常见的“东西”(如名称、描述等)都在“模型”表中,但我仍然可以在“容器”表中使用 STI。或者这是浪费时间,我应该去 STI 做整个事情吗?
在此先感谢,吉姆