OData protocol part1, 11.5.3.2 says:
If the function is bound and the binding parameter type is part of an inheritance hierarchy, the function overload is selected based on the type of the URL segment preceding the function name. A type-cast segment can be used to select a function defined on a particular type in the hierarchy, see [OData-URL].
Say Manager is derived from Employee, if GetEmailsCount is overloaded like below:
<Function Name="GetEmailsCount" IsBound="true" m:IsAlwaysBindable="true">
<Parameter Name="bindingParameter" Type="WebStack.QA.Test.OData.BoundOperation.Employee" />
<ReturnType Type="Edm.Int32" Nullable="false" />
</Function>
<Function Name="GetEmailsCount" IsBound="true" m:IsAlwaysBindable="true">
<Parameter Name="bindingParameter" Type="WebStack.QA.Test.OData.BoundOperation.Manager" />
<ReturnType Type="Edm.Int32" Nullable="false" />
</Function>
If requesting
~/Employees(2)/WebStack.QA.Test.OData.BoundOperation.Manager/WebStack.QA.Test.OData.BoundOperation.GetEmailsCount()
It should find the correct overload, but actually it reports error:
The OData path is invalid.","ExceptionMessage":"Function resolution failed. Multiple functions found in the model with identifier: 'GetEmailsCount' and parameter names : ''.","ExceptionType":"Microsoft.OData.Core.ODataException","StackTrace":"
at System.Web.OData.Routing.FunctionResolver.FindBestBoundFunction(IEnumerable`1 possibleFunctions, IEnumerable`1 parameterNames) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\FunctionResolver.cs:line 79\r\n
at System.Web.OData.Routing.FunctionResolver.TryResolveBound(IEnumerable`1 functions, IEdmModel model, String nextSegment) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\FunctionResolver.cs:line 27\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.TryMatchFunctionCall(String segment, Queue`1 segments, IEdmModel model, IEdmType bindingType) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 573\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.ParseAtEntity(IEdmModel model, ODataPathSegment previous, IEdmType previousEdmType, String segment, Queue`1 segments) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 531\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.ParseNextSegment(IEdmModel model, ODataPathSegment previous, IEdmType previousEdmType, String segment, Queue`1 segments) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 166\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String odataPath) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 54\r\n
at System.Web.OData.Routing.ODataPathRouteConstraint.Match(HttpRequestMessage request, IHttpRoute route, String parameterName, IDictionary`2 values, HttpRouteDirection routeDirection) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\ODataPathRouteConstraint.cs:line 127"}
If the function is bound and the binding parameter type is part of an inheritance hierarchy, the function overload is selected based on the type of the URL segment preceding the function name. A type-cast segment can be used to select a function defined on a particular type in the hierarchy, see [OData-URL].
Say Manager is derived from Employee, if GetEmailsCount is overloaded like below:
<Function Name="GetEmailsCount" IsBound="true" m:IsAlwaysBindable="true">
<Parameter Name="bindingParameter" Type="WebStack.QA.Test.OData.BoundOperation.Employee" />
<ReturnType Type="Edm.Int32" Nullable="false" />
</Function>
<Function Name="GetEmailsCount" IsBound="true" m:IsAlwaysBindable="true">
<Parameter Name="bindingParameter" Type="WebStack.QA.Test.OData.BoundOperation.Manager" />
<ReturnType Type="Edm.Int32" Nullable="false" />
</Function>
If requesting
~/Employees(2)/WebStack.QA.Test.OData.BoundOperation.Manager/WebStack.QA.Test.OData.BoundOperation.GetEmailsCount()
It should find the correct overload, but actually it reports error:
The OData path is invalid.","ExceptionMessage":"Function resolution failed. Multiple functions found in the model with identifier: 'GetEmailsCount' and parameter names : ''.","ExceptionType":"Microsoft.OData.Core.ODataException","StackTrace":"
at System.Web.OData.Routing.FunctionResolver.FindBestBoundFunction(IEnumerable`1 possibleFunctions, IEnumerable`1 parameterNames) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\FunctionResolver.cs:line 79\r\n
at System.Web.OData.Routing.FunctionResolver.TryResolveBound(IEnumerable`1 functions, IEdmModel model, String nextSegment) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\FunctionResolver.cs:line 27\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.TryMatchFunctionCall(String segment, Queue`1 segments, IEdmModel model, IEdmType bindingType) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 573\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.ParseAtEntity(IEdmModel model, ODataPathSegment previous, IEdmType previousEdmType, String segment, Queue`1 segments) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 531\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.ParseNextSegment(IEdmModel model, ODataPathSegment previous, IEdmType previousEdmType, String segment, Queue`1 segments) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 166\r\n
at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String odataPath) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\DefaultODataPathHandler.cs:line 54\r\n
at System.Web.OData.Routing.ODataPathRouteConstraint.Match(HttpRequestMessage request, IHttpRoute route, String parameterName, IDictionary`2 values, HttpRouteDirection routeDirection) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\ODataPathRouteConstraint.cs:line 127"}