【发布时间】:2020-01-24 07:47:23
【问题描述】:
我正在使用 document client 在 Cosmos 数据库中批量插入存储过程,但我面临的挑战是,我需要批量插入可能具有不同 partition keys 的文档。
有什么方法可以实现吗?
我目前正在使用以下代码:
Uri uri = UriFactory.CreateStoredProcedureUri("test-db", "test-collection", "sp_bulk_insert");
RequestOptions options = new RequestOptions { PartitionKey = new PartitionKey("patient")};
var result = await _client.ExecuteStoredProcedureAsync<string>(uri, options , patientInfo, pageInfo);
return result;
但我也有 pageInfo 具有分区键的对象:“page”,但在 RequestOptions 中给出的 PartitionKey 是“耐心”,即 patientInfo 对象的分区键
当我尝试执行 SP 时出现以下错误:
Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted
【问题讨论】:
-
您是否使用批量执行程序库,因为它可以进行分区拆分?
标签: azure azure-cosmosdb azure-cosmosdb-sqlapi