Browse Source
Reset navigation IsModified flags and clear on UoW
Resolve #24806
pull/24857/head
maliming
2 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
25 additions and
3 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ChangeTrackers/AbpEfCoreNavigationHelper.cs
|
|
|
@ -277,7 +277,19 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
finally |
|
|
|
{ |
|
|
|
ChangeTracker.AutoDetectChangesEnabled = true; |
|
|
|
AbpEfCoreNavigationHelper.RemoveChangedEntityEntries(); |
|
|
|
AbpEfCoreNavigationHelper.ResetChangedFlags(); |
|
|
|
if (UnitOfWorkManager.Current != null) |
|
|
|
{ |
|
|
|
UnitOfWorkManager.Current.OnCompleted(() => |
|
|
|
{ |
|
|
|
AbpEfCoreNavigationHelper.Clear(); |
|
|
|
return Task.CompletedTask; |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
AbpEfCoreNavigationHelper.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -222,9 +222,19 @@ public class AbpEfCoreNavigationHelper : ITransientDependency |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual void RemoveChangedEntityEntries() |
|
|
|
public virtual void ResetChangedFlags() |
|
|
|
{ |
|
|
|
EntityEntries.RemoveAll(x => x.Value.IsModified); |
|
|
|
foreach (var entry in EntityEntries.Values) |
|
|
|
{ |
|
|
|
if (entry.IsModified) |
|
|
|
{ |
|
|
|
entry.IsModified = false; |
|
|
|
foreach (var navigation in entry.NavigationEntries) |
|
|
|
{ |
|
|
|
navigation.IsModified = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public virtual void Clear() |
|
|
|
|