public async static Task <DocumentCollection> CreateCollection(CollectionNames collectionName)
        {
            //Set throughput and partition key
            int    reservedRUs  = 9000; //Will have to sleep when we do bulk updates...
            string partitionKey = "/partitionKey";

            PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();

            partitionKeyDefinition.Paths.Add(partitionKey); //Weird.  Cannot have more than one partition key...

            RequestOptions requestOptions = new RequestOptions {
                OfferThroughput = reservedRUs
            };
            ResourceResponse <DocumentCollection> response = await BhProvidersDatabaseDa.DocumentClient.CreateDocumentCollectionIfNotExistsAsync(
                DatabaseUri,
                new DocumentCollection
            {
                Id           = collectionName.ToString(),
                PartitionKey = partitionKeyDefinition
            },
                requestOptions
                );

            DocumentCollection collection = response.Resource;

            return(collection);
        }
 public async static Task DeleteCollection(CollectionNames collectioName)
 {
     Uri collectionUri = UriFactory.CreateDocumentCollectionUri(DatabaseName, collectioName.ToString());
     await BhProvidersDatabaseDa.DocumentClient.DeleteDocumentCollectionAsync(collectionUri);
 }
Пример #3
0
 protected IMongoCollection <T> GetCollection <T>(CollectionNames collection)
 {
     return(GetDatabase().GetCollection <T>(collection.ToString()));
 }