将 HQL 中的术语与当前日期进行比较(使用 .Net)
我想使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自从我使用 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.