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

前端 未结 2 1902
小鲜肉
小鲜肉 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:54

    The DocumentDB LINQ provider does not pick up the JsonConvert.DefaultSettings. In general you can use the DefaultSettings to control camelCase, but for those properties you wish to use in a LINQ Where clause must have the name explicitly set using JsonProperty attribute on your DTO.

    public class User
    {
        public string Id { get; set; }
    
        [JsonProperty("userName")]
        public string UserName { get; set; }
    }
    

    Although a bit tedious and a good source for bugs, it seems to be your only option for now.

提交回复
热议问题