Possible Duplicate:
Can a DbContext enforce a filter policy?
look at this code , this is one of my entities :
class User
{
...
...
...
public bool IsDeleted { get ; set; }
}
when i want to delete an user , i set the IsDeleted property to true and update it. and this is my DbContext :
class DataContext : DbContext
{
...
...
...
public DbSet<User> Users { get; set; }
}
Now here is the question :
How I can change my DbContext to return undeleted object when i just use new DataContext().Users
Sorry about my bad syntax .I am new in English. For more details comment me
UPDATE1 : I change my DBContext to this code , but i got an error
public DbSet<DT.DTO.User> Users
{
get
{
return this.Set<User>().Where(rec => !rec.IsDeleted)
}
set;
}
Error : Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Data.Entity.DbSet'. An explicit conversion exists (are you missing a cast?)