Fluent NHibernate Many to Many Mapping?

I think you have to create an entity for the bridge table!

I think you have to create an entity for the bridge table! Look here: additional fields in Nbernate many-to-many relation tables update I also found this workaround but I've not tested it: Nhibernate many-to-many with extra fields in the join table.

Actually the scenario is I have Roles table and modules table and the relation between these table is many to many , I have an entity name 'Allow' in bridge table to to enable disable the module access anytime – Saad Jul 11 at 6:42 I've updated my post! – danyolgiax Jul 11 at 6:44 ahan Thanks... let me give it a try – Saad Jul 11 at 6:48.

You're mapping the referenced entities AND the foreign key : public OperatorMembershipMap() { Table("USER_OPERATOR_MEMBERSHIP"); Id(x => x. Id, "USER_OPERATOR_MEMBERSHIP_ID").GeneratedBy.Identity(); // Map(x => x. OperatorId, "OPERATOR_ID"); // Map(x => x.

UserRoleId, "USER_ROLE_ID"); References(x => x. Operator). Column("OPERATOR_ID"); ; References(x => x.

UserRole). Column("USER_ROLE_ID"); } You can also remove the foreign keys from your entity : public class OperatorMembership { public virtual int Id { get; set; } // public virtual int OperatorId { get; set; } // delete // public virtual int UserRoleId { get; set; } // delete public virtual UserRole UserRole { get; set; } public virtual Operator Operator { get; set; } }.

If I remove the properties then I cannot access them with my code for an update with these values: op. OperatorId = operatorId; op. UserRoleId = userRoleId; – Randof LoveBottom May 27 at 13:33 Ok, but then you will have the error in your question.

– mathieu May 27 at 14:54 And you can use op. Operator = session. Load(operatorId) – mathieu May 27 at 14:56 hi mathieu, how would I save a new operatormembership row?

If I do not have the 2 properties then I will not be able to save, the operatormembership table is a lookup table for operator and userrole. – Randof LoveBottom May 31 at 10:28 You don't have to map the relationship table : codeproject. Com/KB/database/Nhibernate_Made_Simple.

Aspx – mathieu May 31 at 11:52.

Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate. Get your fluent on. Read the introduction and getting started guide.

Once you've followed the above, you can compare our auto mapping to our fluent interface to see which suits your application, or just see what's available by reading our wiki. Fluent NHibernate wouldn't be possible without the time and effort of its contributors. The team comprises of James Gregory, Paul Batum, Andrew Stewart, and Hudson Akridge.

Our valued committers are: Aaron Jensen, Alexander Gross, Andrew Stewart, Barry Dahlberg, Bobby Johnson, Brian Donahue, Cameron Harris, Chad Myers, Chris Chilvers, Craig Neuwirt, Dan Malcolm, Daniel Mirapalheta, David Archer, David Longnecker, David R.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions