Skip to content

Commit

Permalink
Check if parameter.Name is not null before comparing it with query pa…
Browse files Browse the repository at this point in the history
…rameter

Resolves #20485

Parameters which are used inside lambda should get replaced with appropriate shaper/selector.
All other parameters should be query parameters otherwise it is an error.
  • Loading branch information
smitpatel committed Apr 3, 2020
1 parent d481d1d commit 5a1c2bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ protected override Expression VisitExtension(Expression extensionExpression)

protected override Expression VisitParameter(ParameterExpression parameterExpression)
{
if (parameterExpression.Name.StartsWith(CompiledQueryParameterPrefix, StringComparison.Ordinal))
if (parameterExpression.Name?.StartsWith(CompiledQueryParameterPrefix, StringComparison.Ordinal) == true)
{
return Expression.Call(
_getParameterValueMethodInfo.MakeGenericMethod(parameterExpression.Type),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private Expression VisitContainsMethodCall(MethodCallExpression methodCallExpres
rewrittenSource = Expression.Constant(keyList, keyListType);
}
else if (newSource is ParameterExpression listParam
&& listParam.Name.StartsWith(CompiledQueryCache.CompiledQueryParameterPrefix, StringComparison.Ordinal))
&& listParam.Name?.StartsWith(CompiledQueryCache.CompiledQueryParameterPrefix, StringComparison.Ordinal) == true)
{
// The source list is a parameter. Add a runtime parameter that will contain a list of the extracted keys for each execution.
var lambda = Expression.Lambda(
Expand Down Expand Up @@ -938,7 +938,7 @@ private Expression CreatePropertyAccessExpression(Expression target, IProperty p
// If the target is a query parameter, we can't simply add a property access over it, but must instead cause a new
// parameter to be added at runtime, with the value of the property on the base parameter.
if (target is ParameterExpression baseParameterExpression
&& baseParameterExpression.Name.StartsWith(CompiledQueryCache.CompiledQueryParameterPrefix, StringComparison.Ordinal))
&& baseParameterExpression.Name?.StartsWith(CompiledQueryCache.CompiledQueryParameterPrefix, StringComparison.Ordinal) == true)
{
// Generate an expression to get the base parameter from the query context's parameter list, and extract the
// property from that
Expand Down

0 comments on commit 5a1c2bd

Please sign in to comment.