我有两个类在CosmosDB中代表不同的文件
public class profile
{
public string Id { get; set; }
public string FirstName { get; set; }
//partition key
public string userId{ get; set; }
}
public class Doc
{
public string Id { get; set; }
public string Docname{ get; set; }
//partition key
public string userId{ get; set; }
}
我为可以存储为文档的类创建了对象
profile profileobj= new profile ()
{
Id = "XYZ",
FirstName = "Satya",
userId=1
}
Doc Docobj= new Doc()
{
Id = "XYZ",
Docname= "abc",
userId=1
}
List<dynamic> DocumentList = new List<dynamic>();
DocumentList.Add(profileobj);
DocumentList.Add(Docobj);
插入的方法
public async Task<StoredProcedureResponse<dynamic>> ExecuteStoredProcedureAsync(string procedureName, string partitionKey, List<dynamic> documentList)
{
StoredProcedure storedProcedure = client.CreateStoredProcedureQuery(collection.StoredProceduresLink)
.Where(sp => sp.Id == procedureName)
.AsEnumerable()
.FirstOrDefault();
return await client.ExecuteStoredProcedureAsync<dynamic>(storedProcedureLink: storedProcedure.SelfLink, options: new RequestOptions { PartitionKey = new PartitionKey(partitionKey) }, procedureParams: documentList);
}
我不知道它为什么显示错误
Message: {"Errors":["Encountered exception while executing function. Exception = Error: {\"Errors\":[\"Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.\"]}\r\nStack trace: Error: {\"Errors\":[\"Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.\"]}\n at callback (bulkImport.js:45:18)\n at Anonymous function (bulkImport.js:678:29)"]}