Closed Mortana89 closed 5 years ago
Cosmos DB doesn't support both Query and LINQ predicates in the same DocumentQuery so the line you pasted isn't supported.
I think QueryMultiple would work but why don't you just use Query with WithPagination?
Here is an example: https://github.com/Elfocrash/Cosmonaut/blob/develop/samples/Cosmonaut.Console/Program.cs#L125
Cosmos DB doesn't support both Query and LINQ predicates in the same DocumentQuery so the line you pasted isn't supported.
I think QueryMultiple would work but why don't you just use Query with WithPagination?
Here is an example: https://github.com/Elfocrash/Cosmonaut/blob/develop/samples/Cosmonaut.Console/Program.cs#L125
I use Query with WithPagination for all our 'list' api's, but this one's a bit special, there's no POCO behind the resultset I want to fetch. All the other list api's have a poco object where the result is casted to, but here I just need a string...
Why don't you used the CosmonautClient
then? You can use the QueryDocumentsAsync<>
method and set the generic T to be a string. Then just add WithPagination
on your request.
That works, but where do you get the continuation token in the response from? As I can't seem to find it in the cosmonaut client :/
var results = await mdStore.CosmonautClient.QueryDocumentsAsync<string>( mdStore.DatabaseName, mdStore.CollectionName, queryHelper.Query, queryParams, new Microsoft.Azure.Documents.Client.FeedOptions() { EnableCrossPartitionQuery = true, RequestContinuation = continuationToken } );
Sorry I meant the Query<T>
method.
mdStore.CosmonautClient.Query<string>(mdStore.DatabaseName, mdStore.CollectionName, queryHelper.Query, queryParams).WithPagination().ToPagedListAsync()
Closing this due to inactivity. Feel free to re-open it if this isn't resolved.
That worked, thanks!
I'm trying to do a select distinct c.fieldName, but I'd like to use pagination for this, to be on the safe side if this list gets big. However, QueryMultiple doesn't seem to support pagination.
Doing .Query("select ...").Select(x => x.FieldName) doesn't seem to work either.
What's the best approach to get a paginated list of strings from Cosmos?