I\'m using IDbCommandTreeInterceptor
to implement soft-delete functionality. Inside standard TreeCreated
method I check whether given query command con
To update softdelete, you can override SaveChanges method, and to create filter, you can use dbContext.Query
which will apply soft delete filter automatically using expression generator.
To filter your soft delete column, you can implement following method, in your DbContext.
public IQueryable Query(){
var ds = this.Set() as IQueryable;
var entityType = typeof(T);
if(!softDeleteSupported)
return ds;
ParameterExpression pe = Expression.Parameter(entityType);
Expression compare = Expression.Equals(
Expression.Property(pe, "SoftDeleted"),
Expression.Constant(false));
Expression> filter =
Expression.Lambda>(compare,pe);
return ds.Where(filter);
}