Skip to content

Avoid a null reference exception in ExpressionKeyVisitor #1536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ protected override Expression VisitConstant(ConstantExpression expression)
{
NamedParameter param;

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