Skip to content

Instantly share code, notes, and snippets.

@yostane
Last active September 15, 2017 19:52
Show Gist options
  • Select an option

  • Save yostane/0675df70b8d96bbae5bea4cc653b90c3 to your computer and use it in GitHub Desktop.

Select an option

Save yostane/0675df70b8d96bbae5bea4cc653b90c3 to your computer and use it in GitHub Desktop.
//The "duration" variable contains Execution time when we delete entities using for loop
using (var context = new VideoGamesDatabaseContext())
{
start = DateTime.Now;
//delete all previous entitiies
foreach (var videoGame in context.VideoGames.Where(predicate))
{
context.Remove(videoGame);
}
context.SaveChanges();
duration = DateTime.Now - start;
}
//The "duration" variable contains Execution time when we delete entities using EF Plus
using (var context = new VideoGamesDatabaseContext())
{
start = DateTime.Now;
var res = context.VideoGames.Where(vg => predicate(vg)).Delete(x => x.BatchSize = 500);
//no need to save context
duration = DateTime.Now - start;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment