我在用着NHibernate
驱动存储库,Fluent
映射并尝试使用Linq to 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
手术。
下面这个面向日期的查询应该如何实现? (using Linq
更好,但我认为标准也很好)。
NHibernate.Linq 提供程序无法转换CompareTo
调用sql。
使用类似的东西:
Retrieve<XValue>(x => x.Timestamp>start && x.Timestamp<end);
附注并避免存储库。这是一个天真的抽象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)