I've got a class Project
and a class Case
, which inherits from Project
.
When having a list of Projects
we might decide later on to make a Case
of the selected Project
. How can I achieve this?
Project:
[ActiveRecord (Table = "projects", Lazy = true), JoinedBase]
public class Project : ActiveRecordValidationBase<Project>
{
private int _id;
[PrimaryKey(PrimaryKeyType.Identity, "id")]
public virtual int Id
{
get { return _id; }
set { _id = value; }
}
}
Case:
[ActiveRecord(Table = "cases", Lazy = true)]
public class Case : Project
{
private int _caseId;
[JoinedKey("case_id")]
public virtual int CaseId
{
get { return _caseId; }
set { _caseId = value; }
}
}
I ho开发者_JAVA百科pe my subject and problem are clear :)
See NHibernate - Changing sub-types, it talks about discriminators, but in principle the answer is the same: either avoid this situation by refactoring, or hack around it with raw SQL.
精彩评论