Can I do Global Query Filters in Entity Framework 6? in the OnModelCreating?

0

I'm trying to do this in EF6. It can? I wanted to make a blobal filter

 protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Cotizacion>().HasQueryFilter(x => x.EstaBorrado = false);
}
    
asked by Antonio David Restrepo Carvaja 15.12.2018 в 02:13
source

1 answer

1

The feature to which you reference can only be implemented in EF Core

Global query filters

Now, there are extensions that allow you to achieve what you raise

Entity Framework Plus

If you analyze the options of this library you will see that it is included

EF + Query Filter Global

And this is compatible with Entity framework 6

The other alternative would be to see working with interceptors

EntityFramework.Filters

as you'll see it is defined when using the library

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
   DbInterception.Add(new FilterInterceptor());
}
    
answered by 15.12.2018 в 14:46