I'm maintaining an oldish app which uses NHibernate 3.3.3.4001
I have a Class called ProcedureField, which has a property called ReportCode, with a mapping that looks like this:
Map(x => x.ReportCode);
The database column is of the same name and is a nullable NVARCHAR(50)
For reasons unknown, when I retrieve a row from the table using the PK, that property is null, when the database has a value. Examples:
session.Get<ProcedureField>(id);
or
session.Query<ProcedureField>().First(pf => pf.Id == id);
All other properties are accounted for.
And here's the super weird part. I sniffed the query using SQL Server Profiler and the actual dynamic SQL which executes DOES return the ReportCode
string. It is just not populating the property.
And for the last bit of weirdness, if I add a new property called ReportCodey
and map that to ReportCode, it works (but I have to leave the existing property)!
Map(x => x.ReportCode);
Map(x => x.ReportCodey).Column("ReportCode");
Upgrading to NHibernate's latest version (or any) is not an option for me as it will break a raft of things in the custom framework which this application uses (damn custom frameworks!).
Anyone encountered weirdness of this nature?
Not really sure if this is an adequate answer, but it resolved my question.
I had created a table which was also called ReportCode
. It looks like that was causing the issue. Strange that NHibernate went weird because a new table had the same name as an existing column in another table.
I dropped the new ReportCode
table and it went back to working again.