Skip to content

Instantly share code, notes, and snippets.

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 JonathanMagnan/f5d7ef68654c007a7194cd19cadb8fd1 to your computer and use it in GitHub Desktop.
Save JonathanMagnan/f5d7ef68654c007a7194cd19cadb8fd1 to your computer and use it in GitHub Desktop.
// using Z.EntityFramework.Plus; // Don't forget to include this.
// DELETE all users inactive for 2 years
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
.Delete();
// DELETE using a BatchSize
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
.Delete(x => x.BatchSize = 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment