我有一个看起来像这样的类设置:
public abstract class Parent
{
public virtual bool IsDeleted { get; set; }
}
public class Child : Parent
{
}
public class Other
{
public virtual ICollection<Child> Children { get; set; }
}
Child 被映射为 Parent 的连接子类。Childen 被映射为多对一包。该袋子应用了一个名为 SoftDeletableFilter 的过滤器。过滤器映射如下所示:
<filter-def name="SoftDeleteableFilter" condition="(IsDeleted = 0 or IsDeleted is null)" />
这个问题是,当加载 Other.Children 时,过滤器被应用于子表而不是父表。有没有办法告诉 NHibernate 将过滤器应用于父类?
编辑:这是父映射:
<class name="Parent">
<id ..
<property name="IsDeleted" type="System.Boolean">
<column name="IsDeleted" />
</property>
<joined-subclass name="Child">
<key>
<column name="ParentId" />
</key>
...
</joined-subclass>
</class>