Skip to content

Commit bea25bf

Browse files
Avoid a null reference exception in ExpressionKeyVisitor
1 parent 93d7246 commit bea25bf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ protected override Expression VisitConstant(ConstantExpression expression)
8181
{
8282
NamedParameter param;
8383

84+
if (_constantToParameterMap == null)
85+
throw new InvalidOperationException("Cannot visit a constant without a constant to parameter map.");
8486
if (_constantToParameterMap.TryGetValue(expression, out param) && insideSelectClause == false)
8587
{
8688
// Nulls generate different query plans. X = variable generates a different query depending on if variable is null or not.
@@ -243,4 +245,4 @@ private void VisitMethod(MethodInfo methodInfo)
243245
}
244246
}
245247
}
246-
}
248+
}

0 commit comments

Comments
 (0)