I have mapped a class hierarchy in NHibernate. Simple as that:
class abstract Animal
class Dog : Animal
class Cat: Animal
class Cow: Animal
In mapping I have discriminator values set on ANIMAL_TYPE column:
Dog -> dog
Cat -> cat
Cow -> cow
All kind of queries work. Except this one, when I need to fetch objects of two particular types. I wrote is like this:
QueryOver.Of<Animal>().Where(animal => animal is Dog || theme is Cat)
And I receive no items in result. When I look into generated query, NHibernate generates:
(this_.ANIMAL_TYPE = @p0 or this_.ANIMAL_TYPE = @p1)
which is fine, but the values in @p0 and @p1 parameters contain full class name, eg.
Zoo.Model.Cat
instead of discriminator values. How can I solve it? Do I have to keep my discriminator values in sync with type names? I would like to avoid it if possible.