예제 #1
0
        static async Task deleteDocuments(string dbname, string cname, int maxCount)
        {
            log($"deleteDocuments; db: {dbname}, container: {cname}, maxCount: {maxCount}");

            CosmosUtil cu = new CosmosUtil();
            await cu.setCurrentDatabase(dbname);

            await cu.setCurrentContainer(cname);

            string         sql   = $"select * from c";
            List <dynamic> items = await cu.queryDocuments(sql, maxCount);

            log($"deleteDocuments, count: {items.Count}");
            for (int i = 0; i < items.Count; i++)
            {
                Console.WriteLine(items[i]);
                log($"deleting item: {items[i].id}, {items[i].pk}");
                string          id  = items[i].id;
                string          pk  = items[i].pk;
                GenericDocument doc = new GenericDocument();
                doc.id = items[i].id;
                doc.pk = items[i].pk;

                ItemResponse <GenericDocument> response = await cu.deleteGenericDocument(doc);

                log($"status code:    {response.StatusCode}");
                log($"request charge: {response.RequestCharge}");
            }
        }
예제 #2
0
        public async Task <ItemResponse <GenericDocument> > deleteGenericDocument(GenericDocument doc)
        {
            ItemResponse <GenericDocument> response =
                await this.currentContainer.DeleteItemAsync <GenericDocument>(
                    doc.id, new PartitionKey(doc.pk));

            return(response);
        }