1

Closed

OData fail when filtering on enum type

description

The following request always fail with a NotImplementedException:

GET: api/municipality/4/groups?$filter=Type eq 2
(Type is an enum property, the other properties are string, int, etc.)

Stacktrace:
{"Message":"An error has occurred.","ExceptionMessage":"The method or operation is not implemented.","ExceptionType":"System.NotImplementedException","StackTrace":" at Microsoft.Data.OData.Query.MetadataBinder.BindPropertyAccess(PropertyAccessQueryToken propertyAccessToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindBinaryOperator(BinaryOperatorQueryToken binaryOperatorToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.ProcessFilter(QueryNode query, QueryToken filter)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindTree(SyntacticTree syntax)\r\n at System.Web.Http.OData.Query.FilterQueryOption.get_QueryNode()\r\n at System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, Boolean handleNullPropagation, IAssembliesResolver assembliesResolver)\r\n at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, Boolean handleNullPropagation, Boolean canUseDefaultOrderBy)\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action1 beginTrace, Action execute, Action1 endTrace, Action1 errorTrace)\r\n at System.Web.Http.Tracing.Tracers.ActionFilterAttributeTracer.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass412.<Then>b__40(Task1 t)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass452.<ThenImplContinuation>b__44(Object state)"}
Closed Oct 17, 2012 at 9:57 PM by hongyes
Verified it's been fixed in nightly build

comments

Ridermansb wrote Oct 17, 2012 at 3:28 PM

For me the problem persists!
This changeset is already published in this version?

Project sample: http://ge.tt/2r2qhgP?c (in two formats, zip and rar)

My packages
Microsoft.AspNet.WebApi.OData 0.1.0-alpha-120815
Microsoft.Data.Edm 5.1.0-rc2
Microsoft.Data.OData 5.1.0-rc2
Microsoft.Data.OData.Contrib 5.1.0.50918-rc
System.Spatial 5.1.0-rc2

hongyes wrote Oct 17, 2012 at 9:57 PM

Please try our nightly: update-package Microsoft.AspNet.WebApi.OData -IncludePrerelease -source myget.org/F/aspnetwebstacknightly

hongyes wrote Oct 17, 2012 at 10:00 PM

Please use enum string representation instead of its value to compare. For example:
GET: api/municipality/4/groups?$filter=Type eq 'abc'