以下是特定类型类的HQL查询
select a from Animal a
where TYPE(a) in ('Cat', 'Dog')
and a.sex = 'Male'
order by a.name
select a from Animal a
where a.class in ('Cat', 'Dog')
and a.sex = 'Male'
order by a.name
我想知道是否有使用QueryOver的等价物?
答案 0 :(得分:5)
您可以GetType
使用IsIn
QueryOver扩展方法来完成此操作:
session.QueryOver<Animal>()
.Where(a => a.GetType().IsIn(new[] { "Cat", "Dog" })
/* .. etc */
您应该使用NHibernate映射使用的鉴别器值。