I have a scenario where I need to soft delete ~2500 rows at a time. Im looking to see if there is a better way to perform this task to get some quicker response times. Maybe some bulk insert with the audit logging?
Right now the breakdown is as follows:
-Initial select statement into the context is 2mins (very slow)
-Soft Delete update statement is 11secs (slow)
-The Audit log inserts is 41secs (very slow)
I’ve also try to just do a SQL query as a base line and it takes 1sec to perform all tasks.
Here is the code im executing:
//Pull list of everything that needs to be updated
var locationFixtures = Context.LocationFixtures.Where(lf => lf.FixtureId == fixtureId);
foreach (var entity in locationFixtures)
{
Context.LocationFixtures.Attach(entity);
entity.IsDeleted = true;
entity.DeletedDateTime = DateTimeOffset.UtcNow;
}
Context.SaveChanges();
I have a scenario where I need to soft delete ~2500 rows at a time. Im looking to see if there is a better way to perform this task to get some quicker response times. Maybe some bulk insert with the audit logging?
Right now the breakdown is as follows: -Initial select statement into the context is 2mins (very slow) -Soft Delete update statement is 11secs (slow) -The Audit log inserts is 41secs (very slow) I’ve also try to just do a SQL query as a base line and it takes 1sec to perform all tasks.
Here is the code im executing: