Fluent NHibernate - <int> Binding List

I have a class that looks something like this:

 public class User {
      public virtual int ID;
      public virtual string Name;
      public virtual IList<int> userRights;
 }

 I want to make a UserMap : ClassMap<User>

Name matching is not a problem, but I cannot figure out how to match userRights.

Table looks like

UserTable
User_id int
User_Name nvarchar
User_group int

UserRights
User_group int
RightID int

How would you draw this?

+3
source share
1 answer

Well, if you need a list, you need an index. Therefore, I would recommend just doing this ICollection if the order is not significant.

The display should look something like this:

HasMany(x=> x.userRights).Element("RightID").AsBag();

However, looking at your tables, I noticed something strange. You are trying to use one-to-many without having a primary key in the User_Rights table. If you got User_Id in UserRights, this should work.

, .

+2

Source: https://habr.com/ru/post/1708559/


All Articles