【发布时间】:2019-07-11 13:02:29
【问题描述】:
我正在进行 .net api 开发,其中一项任务是根据条件删除一些文档。这些文档驻留在 Cosmos DB 中。
我已经尝试通过存储过程,但没有得到删除记录的正确 SP。我尝试使用带有 where 条件的 select 查询获取文档,并通过循环获取并传递文档 ID,我尝试删除
using DeleteDocumentAsync
//---Deleting Document based on documentId from corresponding DbName,CollectionName-----------//
private async Task DeleteSecurityDocument(string databaseName, string collectionName, string documentName)
{
string endPoint = ConfigurationManager.AppSettings["DocDbEndPoint"];
string masterKey = ConfigurationManager.AppSettings["DocDbmasterKey"];
var client = new DocumentClient(new Uri(endPoint), masterKey);
await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, documentName));
}
【问题讨论】:
-
我以前从未使用过 Cosmos。但是一些简单的谷歌搜索显示DeleteDocumentAsync 返回一个响应对象,而您忽略了它。您是否尝试检查它以查看它可能会告诉您什么信息?
-
您的收藏是否已分区?另外,您使用的是哪个 Cosmos DB API?
标签: c# azure azure-cosmosdb sql-delete