Have either of you looked at Rhino Security? The first post introducing it is here: http://ayende.com/Blog/archive/2008/01/22/Rhino-Security-Overview-Part-I.aspx
I believe it's still living in Rhino Commons. Ben On Tue, Jun 16, 2009 at 7:17 AM, David Perfors<[email protected]> wrote: > > I had the same problem, I solved it by converting the list of enums to > an string when saving it... it is not ideal, but it works. > > class User > { > public IList<Permissions> Permissions { get;set; } > internal string PermissionsString > { > get > { > StringBuilder permissionString = new Stringbuilder(); > foreach(var item in Permissions) permissionString.Append > (",").Append(item.ToString()); > return permissionString.Remove(0,1).ToString(); > } > set > { > string[] values = value.Split(','); > foreach(string item in values) Permisions.Add((Permission) > Enum.Pars(typeof(Permission), item, true)); > } > } > } > > On Jun 15, 10:24 pm, Loki <[email protected]> wrote: >> That's what I'm afraid of...that I can't use my enum and I have to go >> to a class. Or, I'll end up having the class for the permisions and >> the enums just to make the id's easier to read/access in code. Not >> ideal, but I'm tired of being held up by this problem. >> >> On Jun 15, 2:24 pm, Hudson Akridge <[email protected]> wrote: >> >> > If you're doing it that way, Permission really needs to be a class. It is >> > fairly static though, User/UserPermission are going to be your tables that >> > are going to change most often (the only tables changing once your >> > permissions are set up). >> >> > On Mon, Jun 15, 2009 at 11:10 AM, Ben Hyrman <[email protected]> wrote: >> >> > > If I understand >> >> > > You have class User >> > > You have table User >> > > You have table UserPermission >> >> > > Do you have table Permission? >> >> > > Is Permission a fairly static set? >> >> > > On Sun, Jun 14, 2009 at 5:16 PM, Loki<[email protected]> >> > > wrote: >> >> > > > 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. >> >> > -- >> > - >> > Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge-Hide >> > quoted text - >> >> > - Show quoted text - >> >> > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
