我使用“类表继承 - 使用加入了子类”如下所述: http://www.castleproject.org/activerecord/documentation/trunk/usersguide/typehierarchy.html城堡的ActiveRecord JoinedKey未设置
下面的代码部分是从那里复制。
[ActiveRecord("entity"), JoinedBase]
public class Entity : ActiveRecordBase
{
...
private int id;
[PrimaryKey]
private int Id
{
get { return id; }
set { id = value; }
}
}
[ActiveRecord("entitycompany")]
public class CompanyEntity : Entity
{
private int comp_id;
[JoinedKey("comp_id")]
public int CompId
{
get { return comp_id; }
set { comp_id = value; }
}
....
}
现在,当我有加载CompanyEntity和访问ComId属性是始终为0,但继承的id属性包含正确的值。
编辑:
我也许应该补充一点,我们的实体会自动生成,我不想碰发电机。
EDIT2:
好吧,我知道我必须触摸发电机,以使其发挥作用。但仍然为什么不是Active Record设置Comp_id?
问:
我怎么能告诉ActiveRecord的也设置JoinedKey的价值在子类中,这样CompId ==标识?