2016-03-01 40 views
0

使用NHibernate我有一個帳戶,系統設置,不同種類的帳戶(不同的權限等)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

的思考?

回答

0

促進StudentAccount到TeacherAccount

,既要有?不適用於繼承模型。

更改類型?我會用特設的sql查詢來做到這一點。這是一個特殊情況。

+0

它不一定都是。我基本上想要一個學生成爲一名教師。他們不再需要成爲學生,也不需要回到學生身邊。 – ZachLHelms

相關問題