NH-3845 - Make OfType work better with polymorphic mappings
Addresses NH-3845. The ProcessOfType Linq visitor class now handles interfaces and base classes by checking which mapped types that could be in the result set implement the class, then filtering accordingly. If no results are possible, any remaining filters are removed from the query tree to avoid problems with invalid property names.
Because the HQL tree for OfType can now mimic the ".class IN" construct, the In method of HqlTreeBuilder was inadequate to express the tree. Allowing an array of nodes to be passed as the source solves this problem.
I believe that you need to use ExpressionList instead of modifying In
I tried using ExpressionList, and it causes an exception at parse time. When using the HQL construct where EntityName.class in (Some.Class, Some.Other.Class), the parse tree places the two class names (as Ident nodes) as direct children of the InList node, which in turn is the child of the In node. The changes in this commit replicate that behavior.
Ok, understand. Please remove usage of C#6 language features
I found another facet of the same bug, and I'm likely to be amending the pull request once I can create a minimal test case for it.
You will also need to check the caching issues. Please check that query do process correctly with regardless the type you specify.
@hazzik, I'm not entirely sure what you mean when referring to "check the caching issues." Do you have a test case or example of some kind? Or, can you tell me where to look for a similar unit test?
Start exploring from NH-2500 in JIRA. I can provide more resources later
I added two unit test methods to check for cache issues similar to those NH-2500 describes. The tests pass. If there are other scenarios I should check, please let me know.
I'm having some issues with another test case that I found does not pass. I posted to the nhibernate-developers Google Group, so see discussion there once my post is released from moderation.
The Google Group thread has one reply, but more information would be very helpful.
Related to #553. The #553 contains more clear logic, which, I think shall be ported here.
Happy birthday, PR!
I've extracted the issue with unmapped base classes and interfaces to a new feature request NH-3947.
Can you please enable Allow edits from maintainers option on this PR?