繁体   English   中英

NHibernate移动实体到不同的表

[英]NHibernate moving entity to different table

使用NHibernate,我有一个帐户系统设置,具有不同类型的帐户(不同的特权等)。

我想做的,但又想不通的是:将一种帐户类型更改为另一种帐户类型。

设置的基本思路如下。

class Entity
{
  public int Id;
}

class UserAccount : Entity
{
  public string username;
  public string password;
  // additional account details...
}

class StudentAccount : UserAccount
{
  // student specifc information
}

class TeacherAccount : UserAccount
{
  // teacher specific information
}

在提供的示例中,我希望能够将StudentAccount提升为TeacherAccount。

帐户按用户名是唯一的,因此不能有两个帐户具有相同的名称。

StudentAccount和TeacherAccount都具有UserAccount的外键

有什么想法吗?

将StudentAccount提升为TeacherAccount

都是吗? 不适用于继承模型。

改变类型? 我会用临时SQL查询来做到这一点。 这是很特殊的情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM