Right, that's kind of what I was afraid of. Not having heard of anyone doing
it usually means one of two things for me. There's a way to do it that's
obscure, or it's not possible :) I'm leaning towards the latter, I just
didn't want to rule out the former. You can check with the nhuser group, and
maybe someone there knows deeper magic than I do :)
Otherwise, your options are to just map the enum as a property
(traditional), or break it out and turn that into a class and do something
like a states table.

On Mon, Jun 15, 2009 at 9:18 AM, Loki <[email protected]> wrote:

>
> I made an attempt at mapping the enum like a class, but I'm not sure
> how to go about doing so.  There are no properties to use for the linq
> expression.
>
> On Jun 15, 7:42 am, Hudson Akridge <[email protected]> wrote:
> > You may be better off posting to the nh-users group rather than the
> fluent
> > group, as that's more of the problem you're running into here.
> > In my experience, I've never seen an enum able to be mapped to a table
> like
> > a class, so I don't know if that's possible or not. An enum is typically
> > mapped as a property value to a column for a class. Have you attempted to
> > create a classmap for your enum yet? If so and it doesn't work, what's
> the
> > error that you receive? If not, then all you'd have to do is convert your
> > hbm mapping to a fluent mapping and you're good to go.
> >
> >
> >
> >
> >
> > On Sun, Jun 14, 2009 at 4: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 -
> >
>


-- 
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to