@@ -159,11 +159,9 @@ private static IType GetParameterType(
159159 return candidateType ;
160160 }
161161
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 ) ;
167165 // No related MemberExpressions was found, guess the type by value or its type when null.
168166 // When a numeric parameter is compared to different columns with different types (e.g. Where(o => o.Single >= singleParam || o.Double <= singleParam))
169167 // 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(
174172
175173 private class ConstantTypeLocatorVisitor : RelinqExpressionVisitor
176174 {
177- private bool _hqlGenerator ;
178175 private readonly bool _removeMappedAsCalls ;
179176 private readonly System . Type _targetType ;
180177 private readonly IDictionary < ConstantExpression , NamedParameter > _parameters ;
181178 private readonly ISessionFactoryImplementor _sessionFactory ;
182- private readonly ILinqToHqlGeneratorsRegistry _functionRegistry ;
183- public readonly HashSet < ConstantExpression > NotGuessableConstants = new HashSet < ConstantExpression > ( ) ;
184179 public readonly Dictionary < ConstantExpression , IType > ConstantExpressions =
185180 new Dictionary < ConstantExpression , IType > ( ) ;
186181 public readonly Dictionary < NamedParameter , HashSet < ConstantExpression > > ParameterConstants =
@@ -198,7 +193,6 @@ public ConstantTypeLocatorVisitor(
198193 _targetType = targetType ;
199194 _sessionFactory = sessionFactory ;
200195 _parameters = parameters ;
201- _functionRegistry = sessionFactory . Settings . LinqToHqlGeneratorsRegistry ;
202196 }
203197
204198 protected override Expression VisitBinary ( BinaryExpression node )
@@ -269,16 +263,6 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
269263 return node ;
270264 }
271265
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-
282266 return base . VisitMethodCall ( node ) ;
283267 }
284268
@@ -289,11 +273,6 @@ protected override Expression VisitConstant(ConstantExpression node)
289273 return node ;
290274 }
291275
292- if ( _hqlGenerator )
293- {
294- NotGuessableConstants . Add ( node ) ;
295- }
296-
297276 RelatedExpressions . Add ( node , new HashSet < Expression > ( ) ) ;
298277 ConstantExpressions . Add ( node , null ) ;
299278 if ( ! ParameterConstants . TryGetValue ( param , out var set ) )
0 commit comments