次の FNH マッピングがあります。
public class ItemMap : ClassMap<Item>
{
public ItemMap ()
{
this.HasManyToMany(a => a.ChildItems).ChildWhere("IsDeleted = 0").AsSet();
}
}
結果の hbm ファイルは次のとおりです。
<hibernate-mapping>
<class name="Item" table="Item">
<set name="ChildItems" table="ItemsToChildItems">
...
<many-to-many class="ChildItem" where="IsDeleted = 0">
<column name="ChildItemId" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
NHibernate 3.2 の「コード機能によるセクシーなマッピング:-) / コンフォームド アプローチ」を使用して同じマッピングを実装したい
注: 次のアプローチは機能しません。
public class ItemMap : ClassMapping<Item>
{
public ItemMap()
{
this.Set(x => x.ChildItems
, map =>
{
map.Where("IsDeleted = 0");
}
, action => action.ManyToMany());
}
}
理由: FNH マッピングに従っている:
public class ItemMap : ClassMap<Item>
{
public ItemMap ()
{
this.HasManyToMany(a => a.ChildItems).Where("IsDeleted = 0").AsSet();
}
}
.Where("IsDeleted = 0") と .ChildWhere("IsDeleted = 0") は同じではありません。
HBM の違い:
使用した結果の hbm ファイル.ChildWhere("IsDeleted = 0")
は次のとおりです。
<hibernate-mapping>
<class name="Item" table="Item">
<set name="ChildItems" table="ItemsToChildItems">
...
<many-to-many class="ChildItem" where="IsDeleted = 0">
<column name="ChildItemId" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
使用した結果の hbm ファイル.Where("IsDeleted = 0")
は次のとおりです。
<hibernate-mapping>
<class name="Item" table="Item">
<set name="ChildItems" table="ItemsToChildItems" where="IsDeleted = 0">
...
<many-to-many class="ChildItem">
<column name="ChildItemId" />
</many-to-many>
</set>
</class>
</hibernate-mapping>
誰が同様の問題を抱えているか、解決策を提供できますか? 助けが必要。