How to map this class in NHibernate (not FluentNHibernate)?
Posted
by JMSA
on Stack Overflow
See other posts from Stack Overflow
or by JMSA
Published on 2010-03-04T20:00:46Z
Indexed on
2010/03/08
15:36 UTC
Read the original article
Hit count: 150
nhibernate
|nhibernate-mapping
Suppose I have a database like this:
This is set up to give role-wise menu permissions.
Please note that, User
-table has no direct relationship with Permission
-table.
Then how should I map this class against the database-tables?
class User
{
public int ID { get; set; }
public string Name { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public bool? IsActive { get; set; }
public IList<Role> RoleItems { get; set; }
public IList<Permission> PermissionItems { get; set; }
public IList<string> MenuItemKeys { get; set; }
}
This means,
(1) Every user has some Role
s.
(2) Every user has some Permission
s (depending on to Role
s).
(3) Every user has some permitted MenuItemKey
s (according to Permission
s).
How should my User.hbm.xml
look like?
© Stack Overflow or respective owner