[JsonIgnore]
当我想同时排除set和get时,这是非常好的。
public class NamTable
{
[JsonIgnore]
public long id { get; set; }
public string name { get; set; }
public string mail { get; set; }
public string mobile { get; set; }
[JsonIgnore]
public System.DateTime timestamp { get; set; }
}
例如
id
和
timestamp
它们在插入或设置期间不需要,但我在执行get请求时需要它们。那么我需要添加哪些注释来实现这一点呢?
public class NamTable
{
public long id { get; [JsonIgnore] set; }
public string name { get; set; }
public string mail { get; set; }
public string mobile { get; set; }
public System.DateTime timestamp { get; [JsonIgnore] set; }
}