1
votes

I have webservice that host in Azure. My database is stored in cosomos-db. I want to delete multiple documents via c# code, according to some logic (not all the documents in the collection). Can I delete multiple document via query ? (delete document one by one it's not efficient)

Tody I delete via the following code :

await _client.DeleteDocumentAsync(uri);
1

1 Answers

0
votes

You have to delete each document individually.

If you don't want to make multiple client calls to Cosmos DB, you can execute your multi-delete in a stored procedure. This also has the advantage of treating all document deletes transactionally: everything either succeeds or fails, atomically, within the stored procedure.