konzo
konzo

Reputation: 2093

How to filter breeze.webapi returned entities from the server

I have a standard breeze web-server which exposes the Project

[HttpGet]
public IQueryable<Project> Projects()
{
    return _db.Context.Projects;
}

How can i prevent a Project with NoLongerExist=true from begin included in queries returned to the JavaScript client from here affecting the functionality of the breezejs client?.. um i would also like to hide this property also, people wont like to see that their projects are not actually deleted!

Upvotes: 0

Views: 50

Answers (1)

Tavitos
Tavitos

Reputation: 122

you can try this on your breeze controller...

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

prevent json serialization of the NoLongerExist property using data annotations on your model by doing this, i'm assuming you are using EF6 with JSON.NET on your backend...

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

    }

    public int id { get; set; }

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

Upvotes: 1

Related Questions