-
Notifications
You must be signed in to change notification settings - Fork 136
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
Operations applying query options after custom code #642
Comments
We found that modifying code inside RTestierController::Get function like ythis makes it work.
In your opinion Is this correct? Thank you. |
Mike, let's discuss this next week during the standup. @andreav join us at 12pm EST at https://bit.ly/RESTierYouTube if you'd like to participate. |
As I understand the issue, this is the correct behavior; according to protocol, any query options (such as $filter) are applied to the result of an action or function, not to the input set. OData 4.01 introduced a "filter segment" which can be used to apply a filter to the set that a function or action is bound to. The syntax would be something like: http://localhost:1406/ApiV1/Account/$filter(Id eq 2)/My.DataModel.FunctionExample() There is limitted support for the filter segment in the OData Library and WebAPI OData, but this is not currently supported in RESTier. |
Thank You for the clarification. However I do not understand that behavior. I though bound operations were meant to operate on a subset of the whole rows. My use case can help explain me: Which is the point of retrieving everything and then throwing away 90%? As I said, this is just my use case, sure there is some good reason. Thank you. |
Alright, so we talked about this a bit in the Community Standup yesterday. I think it's best to explain what is going on in the context of C# functions and how compiled languages work. The behavior you were expecting is exactly the same as what I personally would have expected, but once I looked at it this way, the behavior made sense. I want to start out by pointing out that the URL you used as an example is slightly flawed. If "Account" is an EntitySet, then it should be plural ("Accounts"). For the rest of this discussion, I will be referring to it in the correct plural form. Original Query
The order of operations here is this:
The parenthesis in the original query show that you've already called the function, then the filter is applied to the result of that function. What you're actually looking for is something closer to this:
This wasn't actually possible in OData v3 or v4. However, the v4.01 spec was just ratified, and you will be able to do accomplish what you're looking for in the next major release of both WebApi OData and Restier, but with a slightly different syntax. 4.01 Semantics
Hopefully this makes sense. We will be adding a Unit Test to cover this type of a query, and I will make sure we update the Restier documentation to cover this type of scenario. Let me know what you think. Special thanks to @mikepizzo for explaining this to me, so I could explain it to you 🙂. |
I'm going to go ahead and close this, as it is not a bug, but I've referred to it in my documentation task, and we can still keep discussing it if you so desire. Thanks for your input! |
Thank you Robert & Mike for the detailed explanation.
I understand the point, and I will try the new version as soon as it will
be released.
Il mer 10 lug 2019, 17:49 Robert McLaws <notifications@github.com> ha
scritto:
… I'm going to go ahead and close this, as it is not a bug, but I've
referred to it in my documentation task, and we can still keep discussing
it if you so desire. Thanks for your input!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#642?email_source=notifications&email_token=AAKLTYAROXMBUWIDHDI552TP6YAHNA5CNFSM4HYW6IXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZT4YMA#issuecomment-510118960>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKLTYB7Y447HO23TJZSLMTP6YAHNANCNFSM4HYW6IXA>
.
|
Assemblies affected
RESTier-1.0.0
Reproduce steps
Expected result
Actual result
Additional details
Example function:
Example invoking url
The text was updated successfully, but these errors were encountered: