@@ -93,8 +93,8 @@ internal static void SetParameterTypes(
93
93
continue ;
94
94
}
95
95
96
- namedParameter . Type = GetParameterType ( sessionFactory , constantExpressions , visitor , namedParameter , out var tryProcessInHql ) ;
97
- namedParameter . IsGuessedType = tryProcessInHql ;
96
+ namedParameter . Type = GetParameterType ( sessionFactory , constantExpressions , visitor , namedParameter , out var isGuessedType ) ;
97
+ namedParameter . IsGuessedType = isGuessedType ;
98
98
}
99
99
}
100
100
@@ -147,9 +147,9 @@ private static IType GetParameterType(
147
147
HashSet < ConstantExpression > constantExpressions ,
148
148
ConstantTypeLocatorVisitor visitor ,
149
149
NamedParameter namedParameter ,
150
- out bool tryProcessInHql )
150
+ out bool isGuessedType )
151
151
{
152
- tryProcessInHql = false ;
152
+ isGuessedType = false ;
153
153
// All constant expressions have the same type/value
154
154
var constantExpression = constantExpressions . First ( ) ;
155
155
var constantType = constantExpression . Type . UnwrapIfNullable ( ) ;
@@ -159,10 +159,7 @@ private static IType GetParameterType(
159
159
return candidateType ;
160
160
}
161
161
162
- if ( visitor . NotGuessableConstants . Contains ( constantExpression ) && constantExpression . Value != null )
163
- {
164
- tryProcessInHql = true ;
165
- }
162
+ isGuessedType = true ;
166
163
167
164
// No related MemberExpressions was found, guess the type by value or its type when null.
168
165
// When a numeric parameter is compared to different columns with different types (e.g. Where(o => o.Single >= singleParam || o.Double <= singleParam))
@@ -174,13 +171,10 @@ private static IType GetParameterType(
174
171
175
172
private class ConstantTypeLocatorVisitor : RelinqExpressionVisitor
176
173
{
177
- private bool _hqlGenerator ;
178
174
private readonly bool _removeMappedAsCalls ;
179
175
private readonly System . Type _targetType ;
180
176
private readonly IDictionary < ConstantExpression , NamedParameter > _parameters ;
181
177
private readonly ISessionFactoryImplementor _sessionFactory ;
182
- private readonly ILinqToHqlGeneratorsRegistry _functionRegistry ;
183
- public readonly HashSet < ConstantExpression > NotGuessableConstants = new HashSet < ConstantExpression > ( ) ;
184
178
public readonly Dictionary < ConstantExpression , IType > ConstantExpressions =
185
179
new Dictionary < ConstantExpression , IType > ( ) ;
186
180
public readonly Dictionary < NamedParameter , HashSet < ConstantExpression > > ParameterConstants =
@@ -198,7 +192,6 @@ public ConstantTypeLocatorVisitor(
198
192
_targetType = targetType ;
199
193
_sessionFactory = sessionFactory ;
200
194
_parameters = parameters ;
201
- _functionRegistry = sessionFactory . Settings . LinqToHqlGeneratorsRegistry ;
202
195
}
203
196
204
197
protected override Expression VisitBinary ( BinaryExpression node )
@@ -269,16 +262,6 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
269
262
return node ;
270
263
}
271
264
272
- // For hql method generators we do not want to guess the parameter type here, let hql logic figure it out.
273
- if ( _functionRegistry . TryGetGenerator ( node . Method , out _ ) )
274
- {
275
- var origHqlGenerator = _hqlGenerator ;
276
- _hqlGenerator = true ;
277
- var expression = base . VisitMethodCall ( node ) ;
278
- _hqlGenerator = origHqlGenerator ;
279
- return expression ;
280
- }
281
-
282
265
return base . VisitMethodCall ( node ) ;
283
266
}
284
267
@@ -289,11 +272,6 @@ protected override Expression VisitConstant(ConstantExpression node)
289
272
return node ;
290
273
}
291
274
292
- if ( _hqlGenerator )
293
- {
294
- NotGuessableConstants . Add ( node ) ;
295
- }
296
-
297
275
RelatedExpressions . Add ( node , new HashSet < Expression > ( ) ) ;
298
276
ConstantExpressions . Add ( node , null ) ;
299
277
if ( ! ParameterConstants . TryGetValue ( param , out var set ) )
0 commit comments