I tried to define a many-to-many relationship with the where MappingByCode using MappingByCode 's NH3.2 , but I don't know how to do this.
With FluentNHibernate I can use the ChildWhere() method:
public class ProcedureMap : ClassMap<Procedure> { public ProcedureMap() { this.HasManyToMany(a => a.FormTemplates).ChildWhere("IsDeleted = 0").AsSet(); } }
This code will generate the following HBM:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class xmlns="urn:nhibernate-mapping-2.2" name="Procedure" table="Procedure"> <set name="FormTemplates" table="ProceduresToFormTemplates"> <key foreign-key="FK_Procedures_FormTemplates"> <column name="ProcedureId" /> </key> <many-to-many class="FormTemplate" where="IsDeleted = 0"> <column name="FormTemplateId" /> </many-to-many> </set> </class> </hibernate-mapping>
How can I get the same mapping using MappingByCode from NH3.2 ?
source share