I have a Web Api 2 server, an Entity Framework data layer, and a BreezeJS client. I have some extra properties that aren't mapped to the database that I want to set at query time. Something like:
public class Foo
{
// Various mapped properties
// ...
// These properties are not mapped, and I want
// to set them on the returned data depending
// on the current user's roles/authorization
public bool CanEdit { get; set; }
public bool CanDelete { get; set; }
}
[BreezeController]
public class BreezeController : BaseController
{
// ...
[HttpGet]
public IQueryable<Foos> Users()
{
// How can I set the CanEdit and CanDelete properties
// here (and only on the data as filtered by the OData
// queries)?
return Db.Foos; // Db.Foos is a DbSet<Foo>
}
}
Is there any way to do this?
Note: The logic to determine CanEdit
/CanDelete
will be too complex to be encompassed in a LINQ to Entities query.