Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartsWith/Endswith not supported when chaining Odata calls #1144

Closed
henning-krause opened this issue Apr 5, 2018 · 8 comments
Closed

StartsWith/Endswith not supported when chaining Odata calls #1144

henning-krause opened this issue Apr 5, 2018 · 8 comments
Labels

Comments

@henning-krause
Copy link
Contributor

I have a scenario where I need to call a Service via another service:

Client -> ServiceA -> ServiceB

ServiceA and ServiceB both expose their data via OData. So when I call ServiceA with

http://localhost:7071/Services(1)/DataItems

it should query ServiceB, fetch the data and return it to the client.

I've attached a sample solution doing just that: SampleApplication.zip.
Note: The sample App needs to be run as Administrator, otherwise it's not allowed to control the ports. And Just my code needs to be disabled to get the actual error message.

For most queries, this works just fine and I can even filter on the DataItems, as long as I'm using operators like equals, greater than, etc.

But if I run this query:

http://localhost:7070/odata/v4/Services(1)/DataItems?$filter=startswith(Name,'a')

I get this error:

System.NotSupportedException: 'The expression (IIF((([10008].Name == null) OrElse False), null, Convert([10008].Name.StartsWith("a"))) == True) is not supported.'

I've used the latest stable nuget packages as of this morning.

Is this a bug or simply not possible?

@AlanWong-MS
Copy link
Contributor

@henning-krause, your query http://localhost:7070/odata/v4/Services(1)/DataItems?$filter=startswith(Name,'a') should be possible at ODL level. Are you running the query through WebAPI? I noticed that the Frontend.csproj references two different versions of OData. One is 7.4.4 and the other is 5.8.3 (as Microsoft.Data.OData, which was renamed when the version updated to 6.x). It could be that this query wasn't supported in 5.x and there's some sort of mis-route on the version of ODL. We do have a beta version of WebAPI that supports ODL 7.x, if the versioning is the issue.

@henning-krause
Copy link
Contributor Author

@AlanWong-MS, I removed the old nuget package and updated everything else to the latest (prerelease) versions. Still got the same issue: SampleAppV2.zip

And I don't think the Frontend project is the problem. The error occurs in the Middleware project. I do see the call

GET /odata/v4/Services(1)/DataItems?$filter=startswith(Name,'a')

being passed to the Middleware and then the NotSupportedException is thrown in the Middleware process.

And as I said, a simpler filter using only equals or greater than is translated correctly.

@henning-krause
Copy link
Contributor Author

@AlanWong-MS, any news on this one?

@AlanWong-MS
Copy link
Contributor

@xuzhg, any thoughts on this issue?

@henning-krause
Copy link
Contributor Author

@AlanWong-MS, any news?

@henning-krause
Copy link
Contributor Author

I've just upgraded the sample application above to the latest pre-release version, but still, the error occurs.

This should work, shouldn't it?

@ekvanauk
Copy link

This thread is pretty old but I ran into a similar exception and changing the EnableQuery decorator from:
[EnableQuery]
to
[EnableQuery(HandleNullPropagation = Microsoft.AspNet.OData.Query.HandleNullPropagationOption.False)]
solved the issue for me, perhaps it will work for someone else

@KenitoInc
Copy link
Contributor

startswith and endswith functions are supported on all levels of the OData stack.
Examples from our tests


public void DollarThisinFilterInsideSelectInsideExpandShouldReferenceSelectedItem()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants