Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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 want to query like this:
user.Roles
In Fluent NHibernate this is achieved by using HasManyToMany in your mapping. Ex: (User mapping)
HasManyToMany
HasManyToMany(x => x.Roles) .Table("RolesUsers") .ParentKeyColumn("UserId") .ChildKeyColumn("RoleId") .Cascade.All() .Inverse()
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.