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/2554c8f853dc0688a295a24551dfeb8c to your computer and use it in GitHub Desktop.
Save JonathanMagnan/2554c8f853dc0688a295a24551dfeb8c to your computer and use it in GitHub Desktop.
// DELETE all customers that are inactive for more than two years
context.Customers
.Where(x => x.LastLogin < DateTime.Now.AddYears(-2))
.DeleteFromQuery();
// UPDATE all customers that are inactive for more than two years
context.Customers
.Where(x => x.Actif && x.LastLogin < DateTime.Now.AddYears(-2))
.UpdateFromQuery(x => new Customer {Actif = false});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment