I've been trying for some time with no luck on this issue, so I home
someone here has done what I am trying to do.
I have an enum - in my case it is particular permissions for tasks a
person can do - add content, delete content, edit users, delete users,
etc. This is an Enum in my project called Permissions. I want to use
an enum rather than a class object so I can do something like bool
UserHasPermission(Permission.DeleteUser);
Permissions can either be given to a role to allow me to custom build
roles as I need with varied sets of tasks that role can perform, or
given to an individual user. More than one permission can be granted
to a role or user.
In my database, I have the user table and then a UserPermissions table
which maps the user's id to any number of permissions. Now, I will
accept mapping the string value of the enum or the int value. I just
want it to work. I do not want to have to manage 2 sets of
permissions (one in code and one in the database), unless I have to.
If nhibernate could take my enum class and autopopulate a table with
my enum int value for the PK and the name, picking up on changes,
etc., that would be nice.
Right now, I have a mapping where x.Permissions is an IList of type
Permission (my enum).
HasManyToMany(x => x.Permissions)
.WithParentKeyColumn("UserId")
.WithChildKeyColumn("PermissionId")
.WithTableName("UserPermissions")
.LazyLoad();
This mapping errors saying that the type Permission is unmapped.
If anyone can point me in the right direction on mapping a list of
enums to an object, it would be much appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---