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函數將序列化查詢並嚴重傷害查詢性能。 –