Skip to content

Commit a73a2e3

Browse files
author
Bart Koelman
committed
Perf: A more efficient way to reset the change tracker was added in EF Core 5
1 parent 2f1c811 commit a73a2e3

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/JsonApiDotNetCore/Repositories/DbContextExtensions.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using JetBrains.Annotations;
54
using JsonApiDotNetCore.Resources;
@@ -58,12 +57,7 @@ public static void ResetChangeTracker(this DbContext dbContext)
5857
{
5958
ArgumentGuard.NotNull(dbContext, nameof(dbContext));
6059

61-
List<EntityEntry> entriesWithChanges = dbContext.ChangeTracker.Entries().ToList();
62-
63-
foreach (EntityEntry entry in entriesWithChanges)
64-
{
65-
entry.State = EntityState.Detached;
66-
}
60+
dbContext.ChangeTracker.Clear();
6761
}
6862
}
6963
}

0 commit comments

Comments
 (0)