I’ve got two separate projects at the moment that are both using query objects with NHibernate. The primary difference between the code is in the result transformer. One is using AliasToBeanResultsTransformer and the other AliasToBeanConstructorResultsTransformer. I had a problem with the former where the result object was not having any of its properties populated, which I determined to be because the projections were not having the alias defined (second optional property to the Add method). I just wrote a test for a query object in the project using AliasToBeanConstructorResultsTransformer to expose this problem so I could fix it (being a good little TDD developer). The only problem is that the problem doesn’t actually exist when using AliasToBeanConstructorResultsTransformer which obviously doesn’t need the alias specified.
This isn’t really that surprising (I had actually forgotten which result transformer I was using in the project). However I had expected that the AliasToBeanResultsTransformer would be able to match the properties extracted from the domain objects to the equivalent names in the result object. I can see why this isn’t the case due to the potential complexities of projection. I have now learnt not to expect this behaviour and also to test that the correct data is being projected.
I’m aware that “wierdness” is spelt incorrectly in the post title. It amuses me on a deeply trivial level.