Created
July 14, 2020 12:27
-
-
Save zleao/35e14ef5d0c30e30729175a3f4a3293d to your computer and use it in GitHub Desktop.
Portable MongoDB snippet to get a count of the existing collections in a database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var database = client.CreateDatabaseQuery().Where(db => db.Id == Configuration.DatabaseName).ToList().FirstOrDefault(); | |
var feedResult = await client.ReadDocumentCollectionFeedAsync(UriFactory.CreateDatabaseUri(database.Id)); | |
var collectionCount = feedResult.Count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment