ListDocumentsAsync inconsistent with results
See original GitHub issueOS: Linux Mint 19.2 .NET version: 2,2 Package version: Google.Apis.Firestore.v1beta1
I have an ASP.NET Core application where I have an entity that points to a sub-collection of entities.
My code looked like this:
var ret = client.Collection(path).ListDocumentsAsync();
await ret.ForEachAsync(async x =>
{
var y = await x.GetSnapshotAsync();
list.Add(y.ConvertTo<Job>());
});
return list;
Despite having a record in said path
, I kept getting an empty list returned. Only when I went to debug the issue - either by stepping through the repository containing this code or through another part of the stack - did it actually return anything.
Ultimately the fix for this (for me) was to use GetSnapshotAsync
method which returns everything (what I wanted in the first place), but I thought I’d bring it up in case anyone else ran into something similar.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
How to Resolve Sync Conflicts with Sync Center
Resolving sync conflicts · 1. Open the Start Menu and select Control Panel. · 2. Open Sync Center · 3. Select View Sync...
Read more >Inconsistency in %complete with sync of tasks from Project ...
I have a Project 2013 project plan I'm synchronizing with a task list in SharePoint 2013. The %complete does not consistently synchronize ...
Read more >Some documents were not synced at initial sync. After ...
Device 1 signs in with account, documents are created and synced. Device 2 signs in with same account, documents are pulled down. Then...
Read more >How to sync only some but not all folders using sync_list
Documents Creating local directory: Documents/subfolder WARNING: OneDrive API inconsistency - this file does not have any hash: ...
Read more >Tips for syncing items in IBM Content Navigator
If a document gets out of sync with the content that is stored in the repository, you can resolve the sync conflict by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, I understand now. I can reproduce it more simply with my original code, but from the “Now list the contents comment” use:
The problem is that
ForEachAsync
acceptsAction<T>
delegates, notFunc<T, Task>
delegates. It waits for the action to complete, but in the case of an async action, that doesn’t mean the whole lambda expression has completed.It’ll be much easier to handle this in C# 8 with built-in language constructs - although we’re going to need a whole new major version to support that, annoyingly 😦
If you convert the sequence to a list using
var references = await docs.ToList();
and then iterate over the list, that’s probably the best way of doing what you were after. You could potentially write your ownForEachAsync
extension method if you wanted, instead.I’m going to close this now as it’s not really a Firestore issue - do let me know if you want any more details.
Not a problem. You’ve given me more than enough workarounds to continue development, so I’ll go ahead and make the changes I need to work around the issue. Thank you!