question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement CountAsync<TItem>

See original GitHub issue

I would like to request a count of records for a given filter criteria/query. For example: SELECT VALUE COUNT(1) FROM c WHERE c....

When querying CosmosDb directly, this returns a response as follows:

[
    27
]

(In the example above, there are 27 records)

Using the repository, this doesn’t seem possible. Is there a way to use the existing repository to get the above result back, or would a new method be required?

Since all POCOs must derive from IItem, I have tried to create a POCO for the anonymous array response type above but have faced some challenges (with deserialization, etc). I don’t this its possible (but could be wrong, only spent a few minutes experimenting).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mumby0168commented, Aug 6, 2021

Yeah certainly can be done, I have been thinking about an ExistsAsync also.

1reaction
mumby0168commented, Aug 9, 2021

Hi @CarloGarcia would you fancy having ago at implementing this? Feel free to open a draft PR with your idea if you want some feedback 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found