Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: It can not find the correct overload function if the the function is exposed as a function import. [1640]

$
0
0
If a function has 2 overload:
<Function Name="GetAllConventionCustomers" ReturnType="Collection(WebStack.QA.Test.OData.UnboundOperation.ConventionCustomer)" IsComposable="true" />
<Function Name="GetAllConventionCustomers" ReturnType="Collection(WebStack.QA.Test.OData.UnboundOperation.ConventionCustomer)" IsComposable="true">
<Parameter Name="CustomerName" Type="Edm.String" FixedLength="false" Unicode="false" />
</Function>

and it is exposed as a function import:
<FunctionImport Name="GetAllConventionCustomers" Function="WebStack.QA.Test.OData.UnboundOperation.GetAllConventionCustomers" EntitySet="ConventionCustomers" IncludeInServiceDocument="true" />

Then requesting ~/$metadata will result in:

The path template 'GetAllConventionCustomersImport(CustomerName={customerName})' on the action 'GetAllConventionCustomers' in controller 'ConventionCustomers' is not a valid OData path template. The given OData path template 'GetAllConventionCustomersImport(CustomerName={customerName})' is invalid.","ExceptionType":"System.InvalidOperationException","StackTrace":"
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.GetODataPathTemplate(String prefix, String pathTemplate, HttpActionDescriptor action) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 272\r\n
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.<>c__DisplayClass11.<GetODataPathTemplates>b__e(ODataRouteAttribute route) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 243\r\n
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\n
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.BuildAttributeMappings(IEnumerable`1 controllers) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 199\r\n
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.<>c__DisplayClass2.<>c__DisplayClass4.<.ctor>b__1() in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 59\r\n
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.get_AttributeMappings() in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 121\r\n
at System.Web.Http.OData.Routing.Conventions.AttributeRoutingConvention.SelectController(ODataPath odataPath, HttpRequestMessage request) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\Conventions\\AttributeRoutingConvention.cs:line 139\r\n
at System.Web.Http.OData.Routing.ODataPathRouteConstraint.SelectControllerName(ODataPath path, HttpRequestMessage request) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.OData\\OData\\Routing\\ODataPathRouteConstraint.cs:line 181\r\n
at System.Web.Http.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 152\r\n
at System.Web.Http.Routing.HttpRoute.ProcessConstraint(HttpRequestMessage request, Object constraint, String parameterName, HttpRouteValueDictionary values, HttpRouteDirection routeDirection) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\Routing\\HttpRoute.cs:line 215\r\n
at System.Web.Http.Routing.HttpRoute.ProcessConstraints(HttpRequestMessage request, HttpRouteValueDictionary values, HttpRouteDirection routeDirection) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\Routing\\HttpRoute.cs:line 236\r\n
at System.Web.Http.Routing.HttpRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\Routing\\HttpRoute.cs:line 143\r\n
at System.Web.Http.HttpRouteCollection.GetRouteData(HttpRequestMessage request) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\HttpRouteCollection.cs:line 82\r\n
at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\Dispatcher\\HttpRoutingDispatcher.cs:line 67\r\n
at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext() in c:\\WebApi\\aspnetwebstack\\src\\System.Web.Http\\HttpServer.cs:line 223

The controller code snippet is
[HttpGet]
[Queryable]
[ODataRoute("GetAllConventionCustomersImport()")]
public IEnumerable<ConventionCustomer> GetAllConventionCustomers()
{
return _customers;
}

[HttpGet]
[Queryable]
[ODataRoute("GetAllConventionCustomersImport(CustomerName={customerName})")]
public IEnumerable<ConventionCustomer> GetAllConventionCustomers([FromODataUri]String CustomerName)
{
var customers = _customers.Where(c => c.Name.Contains(CustomerName));
return customers;
}

It should choose the correct overload of the function.

Viewing all articles
Browse latest Browse all 7215

Trending Articles