Crash when performing a Linq query on a one-to-one mapped reference


NHibernate fails to add the correct params to a SQL parameterised query when performing a Linq query upon an entity type which is mapped one-to-one. This leads to a crash from the corresponding ADO driver when NHibernate attempts to execute the query. A full reproduction solution is attached but in short, here's the problem:

That query - where the "Person" and "Employee" classes are mapped with a one-to-one relationship - crashes with the following exception:

The reproduction case attached uses a SQLite database, but I have also been able to reproduce it using an MS-SQL database.

Note that I wrote the reproduction case project using Mono, and thus it depends upon Mono.Data.Sqlite at present. If you wish to execute the reproduction case on Windows/.NET, remove the reference to Mono.Data.Sqlite and download/install Sqlite from nuget.

To try the reproduction case (after making any changes for Sqlite), compile and execute the solution (there is only one project). The ReproductionCase class contains the logic which triggers this crash. The EntryPoint class just sets up and configures the session factory and db instance (including creating/exporting the schema).



Debian Wheezy GNU/Linux with Mono:
Mono JIT compiler version 3.12.1 (tarball Fri Mar 6 19:12:47 UTC 2015)

I have also seen this reproducible on a colleagues Windows machine running the official .NET framework 4.5




Craig Fowler


Fix versions

Affects versions