Skip to content

Commit 3bdb598

Browse files
committed
Reduce complexity
1 parent 6d76720 commit 3bdb598

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/NHibernate/Linq/Visitors/ParameterTypeLocator.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ private static IType GetParameterType(
164164
// All constant expressions have the same type/value
165165
var constantExpression = constantExpressions.First();
166166
var constantType = constantExpression.Type.UnwrapIfNullable();
167-
IType type = null;
168167
if (
169168
candidateTypes.Count == 1 &&
170169
// When comparing an integral column with a floating-point parameter, the parameter type must remain floating-point type
@@ -173,20 +172,15 @@ private static IType GetParameterType(
173172
FloatingPointNumericTypes.Contains(constantType))
174173
)
175174
{
176-
type = candidateTypes.FirstOrDefault();
175+
return candidateTypes.First();
177176
}
178177

179178
// No related MemberExpressions was found, guess the type by value or its type when null.
180179
// When a numeric parameter is compared to different columns with different types (e.g. Where(o => o.Single >= singleParam || o.Double <= singleParam))
181180
// do not change the parameter type, but instead cast the parameter when comparing with different column types.
182-
if (type == null)
183-
{
184-
type = constantExpression.Value != null
185-
? ParameterHelper.TryGuessType(constantExpression.Value, sessionFactory, namedParameter.IsCollection)
186-
: ParameterHelper.TryGuessType(constantType, sessionFactory, namedParameter.IsCollection);
187-
}
188-
189-
return type;
181+
return constantExpression.Value != null
182+
? ParameterHelper.TryGuessType(constantExpression.Value, sessionFactory, namedParameter.IsCollection)
183+
: ParameterHelper.TryGuessType(constantType, sessionFactory, namedParameter.IsCollection);
190184
}
191185

192186
private class ConstantTypeLocatorVisitor : RelinqExpressionVisitor

0 commit comments

Comments
 (0)