I have an entity with a DateTime property that is mapped to a table in an Oracle database.
The following query leads to NHibernate using a non-existent date function instead of trunc:
session.Query<MyEntity>().Where(x => x.MyProperty.Date = myDate);
The resulting SQL is something like this:
select <columns> from MY_ENTITY where date(MY_PROPERTY) = :p0;
How to tell NHibernate to use trunc instead?
I am using the ODP.NET provider of NHibernate (OracleDataClientConfiguration.Oracle10).
This issue was fixed about a month ago, but a stable version hasn’t been released yet (as of 15/Feb/2012)
Until that happens, just inherit from
Oracle10gDialectand register the function in the constructor:Then configure NH to use the modified dialect.