将 HQL 中的术语与当前日期进行比较(使用 .Net)

发布于 2024-09-05 16:57:24 字数 320 浏览 1 评论 0原文

我想使用 HQL 将列值与当前日期进行比较。

我尝试过

IQuery someQuery = session.CreateQuery(String.Format(
            @"Select s.Id
            From InventoryProductStateItem s
            where s.ValidFrom < current_date()"));

这会引发异常“关键字 current_date() 附近的语法不正确”

current_date 也不起作用。

I want to compare a column value to the current date, using HQL.

I tried

IQuery someQuery = session.CreateQuery(String.Format(
            @"Select s.Id
            From InventoryProductStateItem s
            where s.ValidFrom < current_date()"));

This throws the exception "Incorrect syntax near keyword current_date()"

current_date does´nt work either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平安喜乐 2024-09-12 16:57:24

自从我使用 NHibernate 以来已经有一段时间了,但我认为有一个名为“current_timestamp”的 hql 函数,NHibernate 中的各种方言实现映射到它们自己的 sql 方言变体。

如果做不到这一点,你总是可以将它变成一个参数。

It's been a while since I used NHibernate, but I think there's a hql function called "current_timestamp" that the various dialect implementations in NHibernate map to their own sql dialect variant.

Failing that, you could always turn it into a parameter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文