Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created July 22, 2021 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/5e20e3eb91b6bade43560c698a941345 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/5e20e3eb91b6bade43560c698a941345 to your computer and use it in GitHub Desktop.
.NET - Entity Framework Core - Global Filters Demo
public class UniversityContext : DbContext
{
public UniversityContext(DbContextOptions<UniversityContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Student>().HasQueryFilter(s => !s.IsDeleted);
}
public DbSet<Student> Students { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment