Does a function call in the Where(...) clause of a Linq to Nhibernate query negatively affect performance?
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?
I would eliminate the CheckVariousProperties(x)
from the query portion and apply it to the returned result of the query.
var myresult= [object].Where(x => x.IsUBuyOrder);
var checkedResult = myresult.Where(x => CheckVariousProperties(x));
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.
精彩评论