public class BaseEntity { public int Id { get; set; }
[JsonIgnore]
public bool IsDeleted { get; set; }
}
public class User : BaseEntity { public new bool IsDeleted { get; set; } }
services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore; });
通过以上方法即可在序列化时忽略基类中被忽略的属性。