1
Vote

Not operator generates invalid OData URL

description

Using LINQPad v4.47.02 (WCF Data Services 5.5), connecting to the NuGet OData feed ( https://nuget.org/api/v2 ), this fails:

Packages
.Where(x => !x.ProjectUrl.Contains("google"))
.Select(x => new {x.Id})

with a very cryptic exception from the server:

"Rewriting child expression from type 'System.Nullable`1[System.Boolean]' to type 'System.Boolean' is not allowed, because it would change the meaning of the operation. If this is intentional, override 'VisitUnary' and change it to allow this rewrite."

The URL generated for the expression above is: https://nuget.org/api/v2/Packages()?$filter=not substringof('google',ProjectUrl)&$select=Id

Replacing the 'not' operator with '== false' works fine:

Packages
.Where(x => x.ProjectUrl.Contains("google") == false)
.Select(x => new {x.Id})

The URL generated for this last expression is: https://nuget.org/api/v2/Packages()?$filter=substringof('google',ProjectUrl) eq false&$top=10&$select=Id

comments