Linq to Nhibernate 查询的Where(...) 子句中的函数调用是否会对性能产生负面影响?
我在我正在构建的应用程序中使用 linq to nhibernate 和 IQueryable.Where 函数。让我感到困惑的是我创建并传递给 INhibernateQueryable 的Where函数的Expression
如何影响性能。
在性能方面,我不太确定在编写这些查询表达式时应该避免哪些问题。如果我传入带有函数调用的表达式,例如:
CurrentSession.Linq<ENTITY>().Where(x => x.IsBuyOrder && CheckVariousProperties(x))
是否会检索每条记录 其中 IsBuyOrder = true
,然后在延迟后立即对它们调用函数 CheckVariousProperties
执行不再推迟?
函数调用如何影响 LinqToNhibernate 性能?
LINQ to Nhibernate 查询表达式中应该避免哪些事情?
I use linq to nhibernate and the IQueryable.Where function in an application I'm building. And what mystifies me is how do the Expression
s I create and pass to the Where function of a INhibernateQueryable affect performance.
I'm not really sure what are the gotchas I should avoid in writing these query Expressions, in terms of performance. If I pass in an expression with a function call like:
CurrentSession.Linq<ENTITY>().Where(x => x.IsBuyOrder && CheckVariousProperties(x))
Is it going to retrieve every record where IsBuyOrder = true
and then call the function CheckVariousProperties
on them as soon as the deferred execution is no longer deferred?
How do function calls affect LinqToNhibernate performance?
What kind of things should be avoided in a LINQ to Nhibernate query Expression?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将从查询部分消除
CheckVariousProperties(x)
并将其应用于查询的返回结果。I would eliminate the
CheckVariousProperties(x)
from the query portion and apply it to the returned result of the query.最好的办法是使用 NHibernate Profiler 来分析您的应用程序。它将能够帮助您识别最大的瓶颈。
The best thing to do is to profile you're application using NHibernate Profiler. It will be able to help you identify your biggest bottlenecks.