I'm using NHibernat in combination with inheritance. That means I have a Parent and a Child object that inherit from each other, but that each have their own mapping file, so seperate tables are created.
I was having issues with the .Any() functionality when I do the following:
I've been debugging the NHibernate source code and I found out that when a Query i performed on an object, it also loops through all other class that inherit from it. This means that for an .Any function call, a result set of booleans is filled. But the strange thing is that in DefaultQueryProvider.cs (line 125) the following happens: return results;
The first result is the .Any result of my ChildObject, so the result from my ParentObject is completely ignored.
I made a UnitTest to prove this behavior:
You would not expect this, but this unit test fails. If I test the same code with a class that doesn't have other classes inherit from it, the unit test passes.
I can make a workaround for this by using:
but I just want to use the Any() functionality.
Does anyone maybe have a solution for this?