private static async Task GetCollections(string project) { FirestoreDb db = FirestoreDb.Create(project); // [START fs_get_collections] DocumentReference cityRef = db.Collection("cities").Document("SF"); IAsyncEnumerable <CollectionReference> subcollections = cityRef.ListCollectionsAsync(); IAsyncEnumerator <CollectionReference> subcollectionsEnumerator = subcollections.GetAsyncEnumerator(default);
public async Task <IList <CollectionReference> > GetDocumentSubcollections(string collectionPath, string documentName) { DocumentReference documentReference = database.Collection(collectionPath).Document(documentName); IList <CollectionReference> subcollections = await documentReference.ListCollectionsAsync().ToList(); return(subcollections); }
private static async Task GetCollections(string project) { FirestoreDb db = FirestoreDb.Create(project); // [START fs_get_collections] DocumentReference cityRef = db.Collection("cities").Document("SF"); IList <CollectionReference> subcollections = await cityRef.ListCollectionsAsync().ToList(); foreach (CollectionReference subcollectionRef in subcollections) { Console.WriteLine("Found subcollection with ID: {0}", subcollectionRef.Id); } // [END fs_get_collections] }
public async Task <SharedDocumentData[]> getSharedDocument(string email) { int sharedDocumentCount = 0; Boolean connectionResult = connectToFirebase(); DocumentReference documentReference = db.Collection("SharedDocuments").Document(email); IAsyncEnumerable <CollectionReference> collectionRefrences = documentReference.ListCollectionsAsync(); IAsyncEnumerator <CollectionReference> enumerator = collectionRefrences.GetAsyncEnumerator(); while (await enumerator.MoveNextAsync()) { CollectionReference collectionReference = enumerator.Current; Query allDocumentsQuery = documentReference.Collection(collectionReference.Id); QuerySnapshot snaps = await allDocumentsQuery.GetSnapshotAsync(); foreach (DocumentSnapshot snap in snaps) { sharedDocumentCount++; } } SharedDocumentData[] sharedDocuments = new SharedDocumentData[sharedDocumentCount]; IAsyncEnumerator <CollectionReference> enumerator1 = collectionRefrences.GetAsyncEnumerator(); int i = 0; while (await enumerator1.MoveNextAsync()) { CollectionReference collectionReference = enumerator1.Current; Query allDocumentsQuery = documentReference.Collection(collectionReference.Id); QuerySnapshot snaps = await allDocumentsQuery.GetSnapshotAsync(); foreach (DocumentSnapshot snap in snaps) { DBSharedDocumentData dBSharedDocumentData = snap.ConvertTo <DBSharedDocumentData>(); sharedDocuments[i] = new SharedDocumentData(); sharedDocuments[i].fileName = dBSharedDocumentData.fileName; sharedDocuments[i].fileLink = dBSharedDocumentData.fileLink; sharedDocuments[i].sharedBy = dBSharedDocumentData.sharedBy; i++; } } return(sharedDocuments); }