/// <inheritdoc/> public override ActionDescriptor SelectAction(RouteContext routeContext, IEnumerable <ControllerActionDescriptor> actionDescriptors) { if (routeContext == null) { throw Error.ArgumentNull("routeContext"); } ODataPath odataPath = routeContext.HttpContext.Request.ODataFeature().Path; HttpRequest request = routeContext.HttpContext.Request; string httpMethod = request.Method.ToUpperInvariant(); if (httpMethod == ODataRouteConstants.HttpGet) { ActionDescriptor actionDescriptor = null; OperationSegment function = null; switch (odataPath.PathTemplate) { case "~/entityset/key/cast/function": case "~/entityset/key/function": function = odataPath.Segments.Last() as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: false); if (actionDescriptor != null) { routeContext.AddKeyValueToRouteData((KeySegment)odataPath.Segments[1], actionDescriptor); } break; case "~/entityset/key/cast/function/$count": case "~/entityset/key/function/$count": function = odataPath.Segments[odataPath.Segments.Count - 2] as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: false); if (actionDescriptor != null) { routeContext.AddKeyValueToRouteData((KeySegment)odataPath.Segments[1], actionDescriptor); } break; case "~/entityset/cast/function": case "~/entityset/function": function = odataPath.Segments.Last() as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: true); break; case "~/entityset/cast/function/$count": case "~/entityset/function/$count": function = odataPath.Segments[odataPath.Segments.Count - 2] as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: true); break; case "~/singleton/function": case "~/singleton/cast/function": function = odataPath.Segments.Last() as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: false); break; case "~/singleton/function/$count": case "~/singleton/cast/function/$count": function = odataPath.Segments[odataPath.Segments.Count - 2] as OperationSegment; actionDescriptor = GetFunction(function).SelectAction(actionDescriptors, isCollection: false); break; } if (actionDescriptor != null) { routeContext.AddFunctionParameterToRouteData(function); return(actionDescriptor); } } return(null); }