public static DocumentCollectionContext CreateCollectionContext(CosmosDbClientConfig config) { DocumentCollectionContext context = new DocumentCollectionContext( client: CosmosDBFactory.CreateClient(config), config: config ); return(context); }
public static async Task DeleteCollectionIfExists(DocumentCollectionContext context) { try { await context.Client.DeleteDocumentCollectionAsync(context.CollectionUri); } catch (DocumentClientException de) { // If the collection does not exist then we can ignore the exception if (de.StatusCode != HttpStatusCode.NotFound) { throw; } } }
public static DocumentCollection GetCollectionIfExists(DocumentCollectionContext context) { return(GetCollectionIfExists(context.Client, context.Config.databaseName, context.Config.collectionName)); }