我有一些代码(已经存在很久了)。看起来像这样:
public async Task CreateAsync(T model, string partitionKey)
{
await _client.CreateDocumentAsync(
UriFactory.CreateDocumentCollectionUri(
_databaseName,
_collectionName
),
model,
new RequestOptions
{
PartitionKey = new PartitionKey(partitionKey)
});
}
我创建了一个新的数据库(cosmos db),当我试图保存一个记录时,我得到了一个错误:
从文档中提取的分区键与标头中指定的分区键不匹配
我使用的JSON如下所示:
{
"_id" : ObjectId("5c3e516647d3c103a0ad0959"),
"gtin" : "4548736035652",
"modelAlias" : "KDL-32WD756",
"modelGroup" : "WD75",
"retailerTitle" : "Sony Bravia 32WD756BU LED HD 1080p Smart TV, 32 with Freeview HD & Cable Management System",
"shortTitle" : "Sony WD75 32 inch Black",
"summary" : "The Sony WD75 in Black is a smart TV, and comes with a 32 inch, full HD, LED screen.",
"variant" : "4548736035645",
"colour" : "Blacks",
"resolution" : "Medium",
"curved" : "No",
"panelType" : "LED",
"3D" : "No",
"size" : "Small",
"goodOnWall" : "No",
"darksAndBrights" : "Medium",
"refreshRate" : "Standard",
"richerColours" : "No",
"wiFi" : "Yes",
"smart" : "Yes",
"recordable" : "Yes",
"latestModel" : "No",
"soundQuality" : "Low",
"voiceActivated" : "No",
"inputs" : "Two",
"pictureQuality" : "Medium",
"brand" : "Sony",
"energyEfficiency" : "Medium",
"sizeBoundary" : "Upper small",
"mountabilityFunction" : "Bad",
"screenSize" : "31-40",
"viewingAngle" : "Wide",
"descriptions" : [
{
"criteriaName" : "Size",
"attributeName" : "Small",
"description" : "Compact screen size"
}
],
"categoryId" : "televisions",
"id" : "94305057-fc1f-3f88-cb74-7056e72077ac"
}