我正在使用NHibernate
驅動存儲庫,Fluent
映射並嘗試使用Linq to NHibernate
。C#NHibernate簡單問題
但對於這樣
Retrieve<XValue>(x => (x.Timestamp.CompareTo(start) >= 0 &&
x.Timestamp.CompareTo(end) <= 0));
// 'Retrieve' here acts simply as 'session.Query<T>().Where(expression);'
我得到以下結果一些簡單的查詢:
System.NotSupportedException: Int32 CompareTo(System.DateTime)
我不知道爲什麼,但CompareTo
操作不投射到數據庫和輸出也有點奇怪:
create table "QuotUnitDescriptor" (
Id integer,
PaperId INTEGER,
Timestamp DATETIME,
InPaperIdx INTEGER,
primary key (Id)
)
NHibernate: INSERT INTO "QuotUnitDescriptor" ......................
// Many INSERT's
NHibernate: select cast(count(*) as INTEGER) as col_0_0_
from "QuotUnitDescriptor" binaryunit0_
我不明白爲什麼這個操作會調用select -> integer
操作。
應該如何實現以下面向日期的查詢?(使用Linq
更好,但標準也很好,我認爲)。
你在比較你的時間戳爲0.也許這是爲什麼? – Vadim 2011-03-21 20:55:41
@Yads我將它與我的代碼中的'start'和'end'時間戳比較。 – 2011-03-21 20:58:28