Browse Source
Provide an option to disable updating the aggregate root when the navigation property changes.
pull/22752/head
maliming
10 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
10 additions and
2 deletions
-
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/AbpEntityChangeOptions.cs
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
|
|
|
@ -8,6 +8,13 @@ public class AbpEntityChangeOptions |
|
|
|
/// </summary>
|
|
|
|
public bool PublishEntityUpdatedEventWhenNavigationChanges { get; set; } = true; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Default: true.
|
|
|
|
/// Update the aggregate root when any navigation property changes.
|
|
|
|
/// Some properties like ConcurrencyStamp,LastModificationTime,LastModifierId etc. will be updated.
|
|
|
|
/// </summary>
|
|
|
|
public bool UpdateAggregateRootWhenNavigationChanges { get; set; } = true; |
|
|
|
|
|
|
|
public IEntitySelectorList IgnoredNavigationEntitySelectors { get; set; } |
|
|
|
|
|
|
|
public AbpEntityChangeOptions() |
|
|
|
|
|
|
|
@ -274,7 +274,7 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (entityEntry.State == EntityState.Unchanged) |
|
|
|
if (EntityChangeOptions.Value.UpdateAggregateRootWhenNavigationChanges && entityEntry.State == EntityState.Unchanged) |
|
|
|
{ |
|
|
|
ApplyAbpConceptsForModifiedEntity(entityEntry, true); |
|
|
|
} |
|
|
|
@ -478,7 +478,8 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (EntityChangeOptions.Value.PublishEntityUpdatedEventWhenNavigationChanges) |
|
|
|
if (EntityChangeOptions.Value.PublishEntityUpdatedEventWhenNavigationChanges && |
|
|
|
EntityChangeOptions.Value.UpdateAggregateRootWhenNavigationChanges) |
|
|
|
{ |
|
|
|
foreach (var entry in AbpEfCoreNavigationHelper.GetChangedEntityEntries() |
|
|
|
.Where(x => x.State == EntityState.Unchanged) |
|
|
|
|