Let’s say you have two tables, ‘Users’ and ‘UserRoles’. Here’s how the two tables are structured (table – columns):
Users – UserID (int)
UserRoles – UserID (int), Role (string)
What I want is for my ‘User’ class in my domain to have an IList of roles. How do I construct my Fluent NHibernate mapping to achieve this?
What you’re looking for is a of a set of elements, which in standard hbm mapping is:
For Fluent NHibernate you can map this like so:
You may need to also specify the key name using
WithKeyColumn(string).