Reputation: 10078
I read everywhere that in OData v3 you should use substringof()
and in v4 you should use contains()
. I installed Microsoft.AspNet.WebApi.OData from NuGet that says version 5.5.1.
Strangely, contains() doesn't work. I am getting the following error:
{"message":"The query specified in the URI is not valid. An unknown function with name 'contains' was found. This may also be a key lookup on a navigation property, which is not allowed." ... }
Conversely, substringof()
works fine. Is it supposed to be that way?
Upvotes: 5
Views: 6045
Reputation: 43
The two NuGet packages which enables OData for WebApi are the following:
Microsoft.AspNet.WebApi.OData for OData v1-3
Microsoft.AspNet.OData for OData v4
Even though v4 does not say WebApi in the name, its still the one to use. The naming has changed and reflects the Package Id (lukehellrunner included these)
Current versions are 5.7.0 for both.
Upvotes: 0
Reputation: 141
The NuGet package version is 5.5.1, but that does not refer to the supported OData version. As OData v1-3 and OData v4 have some non-compatible changes, there are two versions of the WebAPI OData package:
ASP.NET Web API 2.2 for OData v1-3
Package Id: Microsoft.AspNet.WebApi.OData, Version: 5.5.1
ASP.NET Web API 2.2 for OData v4
Package Id: Microsoft.AspNet.OData, Version: 5.6.0
So you are using OData v3 at the moment and the error message is correct, contains() is not defined in OData v3
Upvotes: 7