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

Suppose I have a database like this:

alt text

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 Roles.

(2) Every user has some Permissions (depending on to Roles).

(3) Every user has some permitted MenuItemKeys (according to Permissions).

How should my User.hbm.xml look like?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about nhibernate-mapping