OData.Net doesn't allow $ filter

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 which says version 5.5.1 .

Strange, contains () doesn't work. I am getting the following error:

{"message": "The request specified in the URI is invalid. An unknown function named" contains "was found. This could also be a key lookup for a navigation property that is not allowed" ....}

Conversely, it substringof()

works fine. Is this supposed to be the case?

+3


source to share


2 answers


The NuGet package version is 5.5.1, but this is not the case for the supported OData version. Since OData v1-3 and OData v4 have some incompatible 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

+4


source


The two NuGet packages that enable OData for WebApi are as follows:

Microsoft.AspNet.WebApi.OData strong> for OData v1-3

Microsoft.AspNet.OData strong> for OData v4



Even though v4 doesn't say WebApi in the name, it's still in use. The naming has changed to reflect the package ID (including lukehellrunner)

The current versions are 5.7.0 for both.

0


source







All Articles