从DocumentDB删除文档不会返回已删除的文档

时间:2022-09-29 07:19:22

I'm using this DocumentDB library in my MVC project. When I call DeleteDocumentAsync method in DocumentClient it returns Null. However, if you look at the method signature, it clearly states that it returns a document: public Task<ResourceResponse<Document>> DeleteDocumentAsync(Uri documentUri, RequestOptions options = null);

我在我的MVC项目中使用这个DocumentDB库。当我在DocumentClient中调用DeleteDocumentAsync方法时,它返回Null。但是,如果查看方法签名,它会明确指出它返回一个文档:public Task > DeleteDocumentAsync(Uri documentUri,RequestOptions options = null);

Also in the comments it sais, if that helps:

如果有帮助的话,在评论中也是如此:

// Returns:

//返回:

// The task object representing the service response for the asynchronous operation.

//表示异步操作的服务响应的任务对象。

Any idea why it doesn't return anything? I would expect it to return the deleted document.

知道为什么它不返回任何东西吗?我希望它能够返回已删除的文档。

1 个解决方案

#1


1  

The command DeleteDocumentAsync does not return the deleted record itself, but instead returns a document specifying how many records have been deleted. If you for example run this:

命令DeleteDocumentAsync不会返回已删除的记录本身,而是返回一个文档,指定已删除的记录数。例如,如果你运行这个:

var result = await collection.DeleteDocumentAsync(filter);

You can query the number of deleted records using result.DeletedCount.

您可以使用result.DeletedCount查询已删除记录的数量。

Looking at the source code for the driver it actually returns a DeleteResult document, have a look at the source code on GitHub.

查看驱动程序的源代码,它实际上返回一个DeleteResult文档,看一下GitHub上的源代码。

#1


1  

The command DeleteDocumentAsync does not return the deleted record itself, but instead returns a document specifying how many records have been deleted. If you for example run this:

命令DeleteDocumentAsync不会返回已删除的记录本身,而是返回一个文档,指定已删除的记录数。例如,如果你运行这个:

var result = await collection.DeleteDocumentAsync(filter);

You can query the number of deleted records using result.DeletedCount.

您可以使用result.DeletedCount查询已删除记录的数量。

Looking at the source code for the driver it actually returns a DeleteResult document, have a look at the source code on GitHub.

查看驱动程序的源代码,它实际上返回一个DeleteResult文档,看一下GitHub上的源代码。