C# NHibernate将实体移动到不同的表
使用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
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查询来实现这一点。这是一个非常特殊的情况。不必两者兼而有之。我基本上想让一个学生成为一名教师。他们不再需要成为一名学生,也不再需要回到学生的行列。