Getting DATEPART in HQL or Criteria?

一世执手 提交于 2019-12-11 02:07:26

问题


How can i get DATEPART of a time using HQL or Criteria ? I have googled it up and get some tips, but wasn't enough. If there is someone who has experienced it before, please let us know.

Thanks in advance


回答1:


Take a look at this post about using sql functions in nhibernate from ayende.

EDIT I have had success with something like this in the configuration file :

<property name="query.substitutions">
   true 1, false 0, yes 'Y', no 'N',getdate=getdate
</property>

notice the getdate=getdate, not sure how recommended this is but it is using the sql function :).

More on this : http://www.hibernate.org/hib_docs/nhibernate/html/session-configuration.html , search for query.substitutions.



来源:https://stackoverflow.com/questions/435645/getting-datepart-in-hql-or-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!