Skip to content

Commit 503aec2

Browse files
committed
Merge to single GetCandidateType
1 parent 3c10311 commit 503aec2

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/NHibernate/Linq/Visitors/ParameterTypeLocator.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ internal static void SetParameterTypes(
100100
private static IType GetCandidateType(
101101
ISessionFactoryImplementor sessionFactory,
102102
IEnumerable<ConstantExpression> constantExpressions,
103-
ConstantTypeLocatorVisitor visitor)
103+
ConstantTypeLocatorVisitor visitor,
104+
System.Type constantType)
104105
{
105106
IType candidateType = null;
106107
foreach (var expression in constantExpressions)
@@ -129,28 +130,13 @@ private static IType GetCandidateType(
129130
}
130131
}
131132

132-
return candidateType;
133-
}
134-
135-
private static IType GetCandidateType(
136-
ISessionFactoryImplementor sessionFactory,
137-
HashSet<ConstantExpression> constantExpressions,
138-
ConstantTypeLocatorVisitor visitor,
139-
System.Type constantType)
140-
{
141-
var candidateType = GetCandidateType(sessionFactory, constantExpressions, visitor);
142-
143133
if (candidateType == null)
144-
{
145134
return null;
146-
}
147-
135+
148136
// When comparing an integral column with a real parameter, the parameter type must remain real type
149137
// and the column needs to be casted in order to prevent invalid results (e.g. Where(o => o.Integer >= 2.2d)).
150138
if (constantType.IsRealNumberType() && candidateType.ReturnedClass.IsIntegralNumberType())
151-
{
152139
return null;
153-
}
154140

155141
return candidateType;
156142
}
@@ -161,7 +147,6 @@ private static IType GetParameterType(
161147
ConstantTypeLocatorVisitor visitor,
162148
NamedParameter namedParameter)
163149
{
164-
165150
// All constant expressions have the same type/value
166151
var constantExpression = constantExpressions.First();
167152
var constantType = constantExpression.Type.UnwrapIfNullable();

0 commit comments

Comments
 (0)