Skip to content

Commit 275c9ff

Browse files
committed
Avoid lambda compilation for constant and member access expressions in LINQ
1 parent b13c01a commit 275c9ff

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/NHibernate/Linq/Visitors/NhPartialEvaluatingExpressionVisitor.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Linq.Expressions;
2121
using NHibernate.Collection;
2222
using NHibernate.Engine;
23+
using NHibernate.Impl;
2324
using NHibernate.Linq.Functions;
2425
using NHibernate.Util;
2526
using Remotion.Linq.Parsing;
@@ -143,14 +144,8 @@ private Expression EvaluateSubtree(Expression subtree)
143144

144145
return constantExpression;
145146
}
146-
else
147-
{
148-
Expression<Func<object>> lambdaWithoutParameters = Expression.Lambda<Func<object>>(Expression.Convert(subtree, typeof(object)));
149-
var compiledLambda = lambdaWithoutParameters.Compile();
150147

151-
object value = compiledLambda();
152-
return Expression.Constant(value, subtree.Type);
153-
}
148+
return Expression.Constant(ExpressionProcessor.FindValue(subtree), subtree.Type);
154149
}
155150

156151
#region NH additions

0 commit comments

Comments
 (0)