-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support for direct queries without using the LINQ api #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
Also query from string.
And the README must be updated.
What is not supported at the moment?
Query from string was my 1st goal too. I think this does support string though. Flurl will take whatever object you pass and JSON serialize it to send. If it's a string, it'll serialize to itself. I'm not currently aware of anything not supported, but I wanted a workaround available if I found something else like the Guid |
If you serialize a string it will wrap everything in "". No worries, I'm working on this. public Task<List<TSource>> QueryAsync(string mangoQueryJson)
{
return SendQueryAsync(r => r
.WithHeader("Content-Type", "application/json")
.PostStringAsync(mangoQueryJson));
}
public Task<List<TSource>> QueryAsync(object mangoQuery)
{
return SendQueryAsync(r => r
.PostJsonAsync(mangoQuery));
}
private async Task<List<TSource>> SendQueryAsync(Func<IFlurlRequest, Task<HttpResponseMessage>> requestFunc)
{
var request = NewRequest()
.AppendPathSegment("_find");
var message = requestFunc(request);
var findResult = await message
.ReceiveJson<FindResult<TSource>>()
.SendRequestAsync()
.ConfigureAwait(false);
return findResult.Docs.ToList();
} |
Adds QueryAsync documentation. Adds QueryAsync to README.
And that's why I should've written a test for both use cases... Good catch and thanks for fixing it |
No worries :) |
Provides a workaround for query edge cases that aren't supported