Thanks for your reply, Alex.  The role table has just one column that
I'm using, so I don't really see the point in bringing a table into
the domain.  Ideally, I'd like something like

public enum Role
{
    Module1User = 1,
    Module2User = 2.
    Administrator = 3,
}

public class User
{
    public virtual IList<Role> Roles { set; get; }
}

If that's not possible, I'll do what you suggested and try the many-to-
many, which I think would look like this:

public enum RoleCode
{
    Module1User = 1,
    Module2User = 2.
    Administrator = 3,
}

public class Role
{
    public virtual RoleCode { set; get; }
}

public class User
{
    public virtual IList<Role> Roles { set; get; }
}

Thanks!

On Mar 9, 12:34 pm, "H.Alex" <[email protected]> wrote:
> Maybe you could map that as a many-to-many between the user table and
> the role table. I think the UserRole table wouldn't end up in your
> domain.
> I don't think it matters in this case that a user can only have one
> role. Anyhow, that's how I would hack it :)
>
> On Mar 8, 8:23 pm, mysterd429 <[email protected]> wrote:
>
> > Hi all,
>
> > I'm not sure how to go about solving this using NHibernate.  I have an
> > enumeration, Role, that corresponds to a lookup table in the database,
> > ROLE.  There's a User class that maps to the USER table.  There's also
> > a table, USER_ROLE, that has a composite primary key of USER_ID and
> > ROLE_ID.  I'd like for the User class to have an ISet<Role>, which
> > would indicate which roles they have.
>
> > Obviously, I could create a new class, UserRole, but I think the more
> > OO way would be to use the ISet.  Unfortunately, I'm not really sure
> > how to get started, since the other side of the "many" is basically an
> > integer and not a class.
>
> > Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to