Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ private Expression BindEndsWith(SingleValueFunctionCallNode node)

Contract.Assert(arguments.Length == 2 && arguments[0].Type == typeof(string) && arguments[1].Type == typeof(string));

return ExpressionBinderHelper.MakeFunctionCall(ClrCanonicalFunctions.EndsWith, QuerySettings, arguments);
return ExpressionBinderHelper.MakeCustomFunctionCall(ClrCanonicalFunctions.EndsWith, arguments);
}

private Expression BindCustomMethodExpressionOrNull(SingleValueFunctionCallNode node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ public static Expression MakeFunctionCall(MemberInfo member, ODataQuerySettings
return CreateFunctionCallWithNullPropagation(functionCall, arguments, querySettings);
}

//Custom methods might contain nullable parameters and, therefore, also should be able to take arguments of type Nullable<T>
public static Expression MakeCustomFunctionCall(MethodInfo method, params Expression[] arguments)
{
Expression functionCall;
if (method.IsStatic)
{
functionCall = Expression.Call(null, method, arguments);
}
else
{
functionCall = Expression.Call(arguments.First(), method, arguments.Skip(1));
}

return functionCall;
}

public static Expression CreateFunctionCallWithNullPropagation(Expression functionCall, Expression[] arguments, ODataQuerySettings querySettings)
{
if (querySettings.HandleNullPropagation == HandleNullPropagationOption.True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ protected virtual Expression BindCustomMethodExpressionOrNull(SingleValueFunctio
MethodInfo methodInfo;
if (UriFunctionsBinder.TryGetMethodInfo(node.Name, methodArgumentsType, out methodInfo))
{
return ExpressionBinderHelper.MakeFunctionCall(methodInfo, context.QuerySettings, arguments);
return ExpressionBinderHelper.MakeCustomFunctionCall(methodInfo, arguments);
}

return null;
Expand Down