How can I fluently map 2 entities that are joined together using a "join" table (it has 2 primary keys).
My entities:
Users
Roles
Then the 'join' table looks like:
RolesUsers
RoleId
UserId
So I wan开发者_运维百科t to query like this:
user.Roles
In Fluent NHibernate this is achieved by using HasManyToMany
in your mapping. Ex: (User mapping)
HasManyToMany(x => x.Roles)
.Table("RolesUsers")
.ParentKeyColumn("UserId")
.ChildKeyColumn("RoleId")
.Cascade.All()
.Inverse()
精彩评论