让 NHibernate 对 DateTime.Date 使用 TRUNC
我有一个具有 DateTime
属性的实体,该实体映射到 Oracle 数据库中的表。
以下查询导致 NHibernate 使用不存在的 date
函数而不是 trunc
:
session.Query<MyEntity>().Where(x => x.MyProperty.Date = myDate);
生成的 SQL 类似于:
select <columns> from MY_ENTITY where date(MY_PROPERTY) = :p0;
如何告诉 NHibernate 使用 trunc< /代码> 代替?
我正在使用 NHibernate 的 ODP.NET 提供程序 (OracleDataClientConfiguration.Oracle10
)。
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
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题是大约一个月前已修复,但尚未发布稳定版本(截至 2012 年 2 月 15 日),
在此之前,只需继承
Oracle10gDialect
并注册构造函数中的函数:然后配置 NH 使用修改后的方言。
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
Oracle10gDialect
and register the function in the constructor:Then configure NH to use the modified dialect.