I have the following NHibernate HBM that works as expected, but it makes my code brittle as the classes may change and I want to do the mapping in FNH, but try as I might, I cannot seem to get it to work, especially how you get the index-many-to-many:
<map name="Permissions" table="PermissionsBySet" cascade="all">
<key column="PermissionSet_id" />
<index-many-to-many class="Picomole.ReadModel.Permission, Picomole.ReadModel" column="PermissionId" />
<element column="PermissionType" type="Picomole.ReadModel.PermissionType, Picomole.ReadModel" not-null="true" />
</map>
Given the following classes:
public class PermissionSet : DomainObject
{
public virtual PermissionSet Defaults { get; set; }
public virtual IDictionary<Permission, PermissionType> Permissions { get; set; }
}
public class Permission : DomainObject
{
public virtual string Controller { get; set; }
public virtual string Action { get; set; }
}
public enum PermissionType
{
None,
Read,
Write,
Grant
}