Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uri parser can't work for short data type (Edm.Int16) for function parameter #154

Closed
xuzhg opened this issue Apr 20, 2015 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@xuzhg
Copy link
Member

xuzhg commented Apr 20, 2015

Supposed I have a function as:

<Function Name="ShortFunction" IsBound="true">
    <Parameter Name="bindingParameter" Type="Collection(NS.Customer)" />
    <Parameter Name="number" Type="Edm.Int16" Nullable="false" />
    <ReturnType Type="Edm.String" Unicode="false" />
 </Function>

Then, I call this function as:

~/odata/Customers/Default.ShortFunction(number=1)

It fails as

"Expression of type 'Edm.Int32' cannot be converted to type 'Edm.Int16'."

The call stack is:

   at Microsoft.OData.Core.UriParser.Parsers.MetadataBindingUtils.ConvertToTypeIfNeeded(SingleValueNode source, IEdmTypeReference targetTypeReference)
   at Microsoft.OData.Core.UriParser.Parsers.FunctionCallBinder.BindSegmentParameters(ODataUriParserConfiguration configuration, IEdmOperation functionOrOpertion, ICollection`1 segmentParameterTokens)
   at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.TryBindingParametersAndMatchingOperation(String identifier, String parenthesisExpression, IEdmType bindingType, ODataUriParserConfiguration configuration, ICollection`1& boundParameters, IEdmOperation& matchingOperation)
   at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.TryCreateSegmentForOperation(ODataPathSegment previousSegment, String identifier, String parenthesisExpression)
   at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.CreateNextSegment(String text)
   at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection`1 segments)
   at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)
   at Microsoft.OData.Core.UriParser.ODataUriParser.ParsePathImplementation()
   at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()
   at Microsoft.OData.Core.UriParser.ODataUriParser.ParsePath()
   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath, ODataUriResolverSetttings resolverSettings, Boolean enableUriTemplateParsing) in d:\github\WebApi\OData\src\System.Web.OData\OData\Routing\DefaultODataPathHandler.cs:line 137
   at System.Web.OData.Routing.DefaultODataPathHandler.Parse(IEdmModel model, String serviceRoot, String odataPath) in d:\github\WebApi\OData\src\System.Web.OData\OData\Routing\DefaultODataPathHandler.cs:line 55
   at System.Web.OData.Routing.ODataPathRouteConstraint.Match(HttpRequestMessage request, IHttpRoute route, String parameterName, IDictionary`2 values, HttpRouteDirection routeDirection) in d:\github\WebApi\OData\src\System.Web.OData\OData\Routing\ODataPathRouteConstraint.cs:line 171

I am using Web API 2.2 for OData V4. Thanks.

@lewischeng-ms
Copy link
Contributor

Also consider Edm.Single and Parameter Alias

@lewischeng-ms
Copy link
Contributor

@xuzhg Committed as 4b6c539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants