【发布时间】:2014-11-12 11:21:31
【问题描述】:
我有三个实体类:Entity、Special 和 Regular,其层次结构如下
public class Entity
{
public Guid Id { get; set; }
public bool IsDeleted { get; set; }
}
public class Special : Entity
{
public IEnumerable<Regular> Regulars { get; set; }
}
public class Regular : Entity
{
}
为了映射这个实体,我使用 ClassMap 和 SubclassMap 在我的子类中,我尝试使用 Where 子句从实体 Special 映射集合 Regulars,如下所示:
public class SpecialMap : SubclassMap<Special>
{
public SpecialMap()
{
HasMany(x => x.Regulars).Where("IsDeleted = 0");
}
}
但它不起作用,因为当我尝试使用此集合时,会显示错误 Invalid column name 'IsDeleted'。似乎 nhibernate 试图在表 Regular 中找到 IsDeleted 列,但只有在表 Entity 中没有这样的列。我能用它做什么?
PS。可能我解释不正确,这是我的英语水平:) 这与我的问题NHibernate explicit fluent column mapping 相同,但没有有用的答案
【问题讨论】:
标签: c# fluent-nhibernate mapping where-clause has-many