0
我试图在HQL中选择不同日期时间字段。在HQL中没有时间的独特日期时间字段
select distinct CreatedDate from ClaimFile order by CreatedDate DESC
任何想法我怎样才能得到明确的日期没有时间。现在它不可能随着时间而变得清晰。
感谢
我试图在HQL中选择不同日期时间字段。在HQL中没有时间的独特日期时间字段
select distinct CreatedDate from ClaimFile order by CreatedDate DESC
任何想法我怎样才能得到明确的日期没有时间。现在它不可能随着时间而变得清晰。
感谢
我只能想到几个选项:
CustomSQLFunction
并用它来 日期时间格式化为一个日期。property
映射中使用formula
。 Property Mapping Element Explained <property name="CreateDate" formula="cast(convert(varchar(10),CreateDate,103) as datetime)" />
。
你能给我发一个例子吗?我怎样才能在方言中注册转换sql函数 – user585014
这里有几个链接让你开始:http://ayende.com/blog/1720/using-sql- functions-in-nhibernate http://nhforge.org/blogs/nhibernate/archive/2009/03/13/registering-freetext-or-contains-functions-into-a-nhibernate-dialect.aspx –
还要记住,使用SQL函数将序列化查询并严重伤害查询性能。 –