Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NHibernate将实体移动到不同的表_C#_.net_Database_Nhibernate_Foreign Keys - Fatal编程技术网

C# NHibernate将实体移动到不同的表

C# NHibernate将实体移动到不同的表,c#,.net,database,nhibernate,foreign-keys,C#,.net,Database,Nhibernate,Foreign Keys,使用NHibernate,我建立了一个帐户系统,拥有不同类型的帐户(不同的权限等) 我想做的,但我搞不懂的是:将一种帐户类型更改为另一种帐户类型 设置的基本思想如下 class Entity { public int Id; } class UserAccount : Entity { public string username; public string password; // additional account details... } class Student

使用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的外键

想法

将学生帐户提升为教师帐户

两者兼而有之?继承模型不可行


改变类型?我会使用一个特殊的sql查询来实现这一点。这是一个非常特殊的情况。

不必两者兼而有之。我基本上想让一个学生成为一名教师。他们不再需要成为一名学生,也不再需要回到学生的行列。