我使用Azure Function应用。在应用程序中,我使用microsoft.Azure.DocumentDB v2.9.2包与CommosDB一起使用。我的实体是:
public abstract class Entity
{
[JsonProperty("id")]
public string id { get; set; }
}
public class MyLog : Entity
{
[JsonProperty("createDate")]
public DateTime CreateDate { get; set; }
}
当我用MyLog
序列化Newtonsoft.Json
时,我看到CreateDate
属性是驼峰式的,看起来与JsonProperty
中提到的完全一样,但是当我将实体写入CosmosDB时通过CreateDocumentAsync
方法,我发现CreateDate
现在是帕斯卡大小写,看起来像CreateDate
。要提及的是,没有使用ContractResolver
。我找不到其他任何可以将pascal大小写应用于实体序列化的地方。
[UPDATE]
运行测试时,我看到DB中的属性命名是正确的(考虑到JsonProperty)。仅当azure func写入数据库
时,这是错误的var policy = new ConnectionPolicy();
policy.PreferredLocations.Add("Germany North");
documentClient = new DocumentClient(endPoint,key,policy);
await documentClient.OpenAsync();
...
await documentClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName,collectionName),document);
[/ UPDATE]
有人可以建议其他哪些选项会导致这种行为吗?