简体   繁体   English

通过代码删除documentdb中的多个文档

[英]Delete multiple document in documentdb via code

I have webservice that host in Azure. 我有在Azure中托管的Web服务。 My database is stored in cosomos-db. 我的数据库存储在cosomos-db中。 I want to delete multiple documents via c# code, according to some logic (not all the documents in the collection). 根据某些逻辑,我想通过c#代码删除多个文档(不是集合中的所有文档)。 Can I delete multiple document via query ? 我可以通过查询删除多个文档吗? (delete document one by one it's not efficient) (删除文件效率不高)

Tody I delete via the following code : Tody我通过以下代码删除:

await _client.DeleteDocumentAsync(uri);

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. 如果您不想对Cosmos DB进行多个客户端调用,则可以在存储过程中执行多删除操作。 This also has the advantage of treating all document deletes transactionally: everything either succeeds or fails, atomically, within the stored procedure. 这还具有以事务方式处理所有文档删除的优点:在存储过程中,原子地成功或失败的所有事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM