尝试添加文档时抛出异常
Exception Thrown Trying to Add Document
每次我尝试将文档添加到我的 Azure DocumentDB 时,我都会收到一个包含一个异常的 AggregateException:"Owner resource does not exist"。我使用的代码如下,DbName 和 TransCollection 值是正确的,因为它们在我查询数据库时工作正常,DocumentClient 对象也是如此。
await Client.CreateDocumentAsync("dbs/ " + DbName + "/colls/" + TransCollection, record, null, true).ConfigureAwait(continueOnCapturedContext: false);
有没有人知道我做错了什么,或者至少在哪里寻求更多帮助?
不要自己手动编写 Uri,而是使用这些 DocumentDB SDK 帮助程序:
UriFactory.CreateDocumentCollectionUri("myDbName", "myCollectionName");
或者,对于文档:
UriFactory.CreateDocumentUri("myDbName", "myCollectionName", "idOfDocument");
如图here.
每次我尝试将文档添加到我的 Azure DocumentDB 时,我都会收到一个包含一个异常的 AggregateException:"Owner resource does not exist"。我使用的代码如下,DbName 和 TransCollection 值是正确的,因为它们在我查询数据库时工作正常,DocumentClient 对象也是如此。
await Client.CreateDocumentAsync("dbs/ " + DbName + "/colls/" + TransCollection, record, null, true).ConfigureAwait(continueOnCapturedContext: false);
有没有人知道我做错了什么,或者至少在哪里寻求更多帮助?
不要自己手动编写 Uri,而是使用这些 DocumentDB SDK 帮助程序:
UriFactory.CreateDocumentCollectionUri("myDbName", "myCollectionName");
或者,对于文档:
UriFactory.CreateDocumentUri("myDbName", "myCollectionName", "idOfDocument");
如图here.