Repository navigation
Closed
Description
metadata:
<EntityType Name="Person"><Key><PropertyRef Name="PersonId"/></Key><Property Name="PersonId" Type="Edm.Int64" Nullable="false"><Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/></Property><Property Name="UserName" Type="Edm.String" MaxLength="max"/><Property Name="FirstName" Type="Edm.String" Nullable="false" MaxLength="max"/><Property Name="LastName" Type="Edm.String" MaxLength="26"/><Property Name="Concurrency" Type="Edm.Int64" Nullable="false"/><NavigationProperty Name="Friends" Type="Collection(Microsoft.Restier.WebApi.Test.Services.Trippin.Models.Person)"/><NavigationProperty Name="Trips" Type="Collection(Microsoft.Restier.WebApi.Test.Services.Trippin.Models.Trip)"/></EntityType>
http://localhost:18384/api/TripPin/People%280%29/
Response:
HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata.metadata=minimal
Expires: -1
Server: Microsoft-IIS/8.0
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RDpcZ2l0XHRcUkVTVGllclx0ZXN0XE9EYXRhRW5kVG9FbmRUZXN0c1xNaWNyb3NvZnQuUmVzdGllci5XZWJBcGkuVGVzdC5TZXJ2aWNlcy5UcmlwcGluXGFwaVxUcmlwUGluXFBlb3BsZSgwKVw=?=
X-Powered-By: ASP.NET
Date: Mon, 20 Jul 2015 08:39:23 GMT
Content-Length: 3466
{
"error":{
"code":"","message":"An error has occurred.","innererror":{
"message":"The binary operator Equal is not defined for the types 'System.Int64' and 'System.Int32'.","type":"System.InvalidOperationException","stacktrace":" at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)\r\n at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)\r\n at System.Linq.Expressions.Expression.Equal(Expression left, Expression right)\r\n at Microsoft.Restier.WebApi.ODataDomainController`1.CreateEqualsExpression(ParameterExpression parameterExpression, String propertyName, Object propertyValue) in d:\\git\\t\\RESTier\\src\\Microsoft.Restier.WebApi\\ODataDomainController.cs:line 383\r\n at Microsoft.Restier.WebApi.ODataDomainController`1.ApplyKeys(IQueryable queryable, KeyValuePathSegment keySegment, IEdmEntityType entityType, Type type) in d:\\git\\t\\RESTier\\src\\Microsoft.Restier.WebApi\\ODataDomainController.cs:line 313\r\n at Microsoft.Restier.WebApi.ODataDomainController`1.GetQuery(HttpRequestMessageProperties odataProperties) in d:\\git\\t\\RESTier\\src\\Microsoft.Restier.WebApi\\ODataDomainController.cs:line 510\r\n at Microsoft.Restier.WebApi.ODataDomainController`1.<Get>d__0.MoveNext() in d:\\git\\t\\RESTier\\src\\Microsoft.Restier.WebApi\\ODataDomainController.cs:line 126\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}
}
Activity
karataliu commentedon Jul 20, 2015
Also not work for Int16:
[-][Protocol] Int64 could not be key[/-][+][Protocol] Int64 could not be used as key[/+]karataliu commentedon Jul 30, 2015
Related odatalib issue: OData/odata.net#175
SaucyJack commentedon Feb 17, 2016
Perhaps this is naive, but I solved this problem by changing the construction of the constant in the CreateEqualsExpression method in RestierQueryBuilder so that it converts the property value to the type of the property:
lewischeng-ms commentedon Feb 18, 2016
@SaucyJack Nice solution! Looks good to me. Just one suggestion: can we ignore the second
property.Type? And would you please send a pull request to us for a quick fix? Thanks!SaucyJack commentedon Feb 18, 2016
@lewischeng-ms Ah, I didn't see that there was an overload of Expression.Constant that didn't require the type (why would it require the type anyway, right?). I'll submit a pull request. RESTier is providing me with exactly the solution I need for our API so I'm very excited to use and contribute where I'm able.
lewischeng-ms commentedon Mar 16, 2016
Already done by #294
cilerler commentedon Apr 26, 2016
@SaucyJack unfortunately PUT still throws an error where PATCH, POST, DELETE, GET works just fine.
chinadragon0515 commentedon Apr 27, 2016
@cilerler we always not take a look at closed issues unless someone check the mail notification and see comments, can you open a new issue if you have some issues, I do not want to reopen a closed issue, thanks.
cilerler commentedon Apr 27, 2016
@chinadragon0515 done #380