2

我已经创建了带有驼峰式分区键的集合,例如\locationId而不是\LocationId. 此外,在 cosmosdb 中插入/更新文档时,我已使用以下代码将它们添加为驼峰式:

T entity = null;
var settings = new JsonSerializerSettings 
{ 
      ContractResolver = new CamelCasePropertyNamesContractResolver() 
};

var messageBody = JsonConvert.SerializeObject(entity, Formatting.Indented, settings);

using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(messageBody)))
{
      var res = Resource.LoadFrom<Document>(memoryStream);
      await _client.UpsertDocumentAsync((await _collection).SelfLink, res, option);
}

但是,当使用 linq 条件检索任何文档时,结果始终为空。我已经装饰了所有 CosmosDB T 类型[JsonProperty(PropertyName = "id")]

我在这里错过了什么吗?

4

0 回答 0