using System.Data.Entity;
using System.Collections.Generic;
using Z.EntityFramework.Plus;
public static void Main()
using (var context = new EntityContext())
context.Filter<Post>(q => q
.Where(x => !x.IsSoftDeleted));
var list = context.Posts.ToList();
FiddleHelper.WriteTable("After Filtering", list);
public static void GenerateData()
using (var context = new EntityContext())
context.Posts.Add(new Post() {Title = "Post_A", IsSoftDeleted = false, ViewCount = 12});
context.Posts.Add(new Post() {Title = "Post_B", IsSoftDeleted = true, ViewCount = 41});
context.Posts.Add(new Post() {Title = "Post_C", IsSoftDeleted = false, ViewCount = 24});
using (var context = new EntityContext())
FiddleHelper.WriteTable("Before Filtering", context.Posts.ToList());
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Post> Posts { get; set; }
public int PostId { get; set; }
public string Title { get; set; }
public bool IsSoftDeleted { get; set; }
public int ViewCount { get; set; }