0

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 hope my subject and problem are clear :)

MysticEarth
  • 2,646
  • 4
  • 33
  • 53

1 Answers1

1

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.

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275