Saturday, November 26, 2011

NHibernate MappingByCode ManyToMany

I was not able to find a "loquacious" conformist example about a many-to-many relation mapping, so after play a bit with it, I finally deal with it.
Here an example:

 Bag(x => x.ManyToManyCollection
   , map =>
     {
        map.Table("many_to_many_table_name");
        map.Lazy(CollectionLazy.Lazy);
        map.Key(k => k.Column("child_key_column"));
     }
   , action => action.ManyToMany(m => m.Column("parent_key_column")));

Happy mapping! ^^