我们使用的是NHibernate 2.1,我将系统升级到3.0以测试新的LINQ提供程序.
我比较了 linq提供程序,createquery和queryover.
我比较了 linq提供程序,createquery和queryover.
createquery和queryover几乎完全相同,性能相同.
然而,LINQ提供商做了一些非常时髦的东西!
var items = (from m in NHibernateSession.Current.Query<Listing>() where m.Active == true select m).Take(10).ToList(); var items2 = NHibernateSession.Current.createquery("from Listing where Active = :val").SetBoolean("val",true).SetMaxResults(10).List(); var items3 = NHibernateSession.Current.QueryOver<Listing>() .Where(m => m.Active == true) .Take(10).List();
来自createquery&的sql queryover:
select TOP ( 10 /* @p0 */ ) listing0_.PackageID as PackageID13_,listing0_.MatchComplete as MatchCom2_13_,listing0_.ExpirationDate as Expirati3_13_,listing0_.Active as Active13_,listing0_.Archived as Archived13_,listing0_.Deleted as Deleted13_,listing0_.UserID as UserID13_ from Marketplace.Listings listing0_ where listing0_.Active = 1 /* @p1 */
来自LINQ的查询:
select TOP ( 10 /* @p0 */ ) listing0_.PackageID as PackageID13_,listing0_.UserID as UserID13_ from Marketplace.Listings listing0_ where case when listing0_.Active = 1 then 'true' else 'false' end = case when 'True' /* @p1 */ = 'true' then 'true' else 'false' end
NH Profiler for LINQ的持续时间为37/91,相比之下为2/2
这应该发生吗?或者我错过了一个配置设置,告诉LINQ将布尔比较转换为位?
谢谢
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。