Below are HQL queries for specific type of classes
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
Im wondering is there and equivalent using QueryOver?
You can use GetType
with the IsIn
QueryOver extension method to accomplish this:
session.QueryOver<Animal>()
.Where(a => a.GetType().IsIn(new[] { "Cat", "Dog" })
/* .. etc */
You should use the discriminator values that your NHibernate mapping uses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With