-
Notifications
You must be signed in to change notification settings - Fork 191
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
Can this library be used to generate the request url only? #99
Comments
Sure, that's possible. Here is an example:
|
Thanks. It seems like |
No, it doesn't fire the request for the given command, but it needs to make a single request to fetch metadata document. For simple queries it's possible to generate the URI without knowing metadata, but in general case knowing service metadata is necessary. I can think of the way of providing metadata as a local file, so the client doesn't need to make a network roundtrip. |
The version 4.4 (coming in a day or two) will have ODataClientSettings.MetadataDocument property that you can use to initialize with the service metadata. Then it will not make an extra call to retrieve a metadata document while executing GetCommandTextAsync. |
I see. Thank you very much for your time and your wonderful library. |
And the version 4.4 is out with support for MetadataDocument in ODataClientSettings. |
But still, can't we just use it with simple: Expression<Func<T,bool>> expression = ... I also need a way to translate my linq expression to odata string and nothing else. |
@rekosko you're specifically looking for the translation of a filter expression? In any case the expression it generates would be based on the entities involved. You could remove the base URL from the generated command text. |
I have the same requirement as rekosko, I would like to just translate an Expression<Func<T,bool>> to a odata query string. but before the demo code can work, I need to create an ODataClient with a valid url that host an odata api, if I specify an url like "127.0.0.1", the GetCommandTextAsync will throw HttpRequestException. can we split the GetCommandTextAsync as an mini tool function? |
@cbfrank to generate it, it needs the metadata for the service. Would your client have the metadata locally? |
@watfordgnf sorry, no it doesn't have. actually, the web api is not an odata standard api, it just have a "Get" method which support query string of odata format. this is why I can't provide any url when creating ODataClient. |
Without metadata we cannot properly generate the OData expression. |
@watfordgnf I see. Maybe I can try to create a metadata manually, and then use the GetCommandTextAsync . Is this a possible solution? |
If |
I was looking for a library that could translate a C# filter expression into a proper OData query string. Simple.OData.Client certainly needs to do this internally. My question is: is this functionality somehow exposed? Can I use it to get an OData request URL without actually fetching the objects?
The text was updated successfully, but these errors were encountered: