@@ -159,11 +159,9 @@ 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
- }
166
-
162
+ // Leave hql logic to determine the type except when the value is a char. Hql logic detects a char as a string, which causes an exception
163
+ // when trying to set a string db parameter with a char value.
164
+ tryProcessInHql = ! ( constantExpression . Value is char ) ;
167
165
// No related MemberExpressions was found, guess the type by value or its type when null.
168
166
// When a numeric parameter is compared to different columns with different types (e.g. Where(o => o.Single >= singleParam || o.Double <= singleParam))
169
167
// do not change the parameter type, but instead cast the parameter when comparing with different column types.
@@ -174,13 +172,10 @@ private static IType GetParameterType(
174
172
175
173
private class ConstantTypeLocatorVisitor : RelinqExpressionVisitor
176
174
{
177
- private bool _hqlGenerator ;
178
175
private readonly bool _removeMappedAsCalls ;
179
176
private readonly System . Type _targetType ;
180
177
private readonly IDictionary < ConstantExpression , NamedParameter > _parameters ;
181
178
private readonly ISessionFactoryImplementor _sessionFactory ;
182
- private readonly ILinqToHqlGeneratorsRegistry _functionRegistry ;
183
- public readonly HashSet < ConstantExpression > NotGuessableConstants = new HashSet < ConstantExpression > ( ) ;
184
179
public readonly Dictionary < ConstantExpression , IType > ConstantExpressions =
185
180
new Dictionary < ConstantExpression , IType > ( ) ;
186
181
public readonly Dictionary < NamedParameter , HashSet < ConstantExpression > > ParameterConstants =
@@ -198,7 +193,6 @@ public ConstantTypeLocatorVisitor(
198
193
_targetType = targetType ;
199
194
_sessionFactory = sessionFactory ;
200
195
_parameters = parameters ;
201
- _functionRegistry = sessionFactory . Settings . LinqToHqlGeneratorsRegistry ;
202
196
}
203
197
204
198
protected override Expression VisitBinary ( BinaryExpression node )
@@ -269,16 +263,6 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
269
263
return node ;
270
264
}
271
265
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
266
return base . VisitMethodCall ( node ) ;
283
267
}
284
268
@@ -289,11 +273,6 @@ protected override Expression VisitConstant(ConstantExpression node)
289
273
return node ;
290
274
}
291
275
292
- if ( _hqlGenerator )
293
- {
294
- NotGuessableConstants . Add ( node ) ;
295
- }
296
-
297
276
RelatedExpressions . Add ( node , new HashSet < Expression > ( ) ) ;
298
277
ConstantExpressions . Add ( node , null ) ;
299
278
if ( ! ParameterConstants . TryGetValue ( param , out var set ) )
0 commit comments