c# – 有没有办法防止NHibernate LINQ提供程序的布尔性能问题
发布时间:2020-12-15 21:18:53 所属栏目:百科 来源:网络整理
导读:我们使用的是NHibernate 2.1,我将系统升级到3.0以测试新的LINQ提供程序. 我比较了 linq提供程序,createquery和queryover. Createquery和queryover几乎完全相同,性能相同. 然而,LINQ提供商做了一些非常时髦的东西! var items = (from m in NHibernateSession
我们使用的是NHibernate 2.1,我将系统升级到3.0以测试新的LINQ提供程序.
我比较了 linq提供程序,createquery和queryover. Createquery和queryover几乎完全相同,性能相同. 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将布尔比较转换为位? 谢谢 解决方法
发现解决方案是在3.2.这被报告为一个错误,并为下一个版本修复.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |