Closed DennisBaekgaard closed 4 years ago
Hello @DennisBaekgaard,
If you need anything other than the entity itself then you shouldn't be using the Query
method.
You should use the QueryMultipleAsync<T>
instead.
Here is how your query should be:
var result = await _store.QueryMultipleAsync<string>("SELECT DISTINCT VALUE c.id FROM c");
Hi @Elfocrash
As per usual superb response time and answer. Thanks - I'll see if I can find the time to update your docs a bit for some more clarity if you don't mind.
No problem. Yeah please do. I always forget to document some stuff, 😭. Feel free to close this.
If you have the following store:
services.AddCosmosStore<MyEntity>(cosmosSettings);
And use it in the following way:
var result = await _store.Query("SELECT DISTINCT VALUE c.id FROM c").ToListAsync();
The output from the query is in the form of a list of strings, but cosmonaut tries to cast it to a list of MyEntity.
I was looking through the source, but at least I couldn't find a way to prevent this. Is there a away I can type-cast the expected response to something else than the registered store value?
Basically what I'm trying to do is just counting the distinct amount of entities of type T in cosmos. I get I could just query the actual list of entities and then do the aggregates on that list, but the performance of in-cosmos aggregations are a lot better.