How to tell DocumentDB SDK to use camelCase during linq query?

前端 未结 2 1901
小鲜肉
小鲜肉 2020-12-15 20:24

Considering the document { \"userName\": \"user1\" } stored in the User collection, and the following User class:

public class Use         


        
2条回答
  •  别那么骄傲
    2020-12-15 20:37

    In a similar case with Cosmos DB, I was able to set all properties to Camel case for my objects at the class declaration level, as in:

    [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
    public class User
    {
        public string Id { get; set; }
    
        public string UserName { get; set; }
    }
    

    This is how you tell NewtonSoft.Json to use Camel case for serializing.

提交回复
热议问题