How to prevent or allow json serialization of a property from breeze controller

邮差的信 提交于 2019-12-25 07:16:27

问题


So it happens that you can prevent breeze json serialization of some properties using data annotations on your model by like this(well if you are using EF6 with JSON.NET on the backend)...

[Table("Project")]
public partial class Project
{
    public Project()
    {

    }

    public int id { get; set; }

    [JsonIgnore]
    public bool NoLongerExist  { get; set; }
}

By doing so the property becomes invisible on this endpoint used by breeze

public IQueryable<Project> Projects()
    {
        return _db.Context.Projects.Where(o => o.NoLongerExist == true);
    }

Can i apply [JsonIgnore] based on a certain condition like an authenticated user or a random if from this endpoint?

来源:https://stackoverflow.com/questions/38270062/how-to-prevent-or-allow-json-serialization-of-a-property-from-breeze-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!