From c8fa004de64fd65e5cb741ee24d9bb061ed889cb Mon Sep 17 00:00:00 2001 From: maliming Date: Sun, 4 Jan 2026 18:29:52 +0800 Subject: [PATCH] Refactor event clearing methods with null-conditional operator --- .../Abp/Domain/Entities/BasicAggregateRoot.cs | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs index 826233d5a3..5680f9e857 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs @@ -25,22 +25,12 @@ public abstract class BasicAggregateRoot : Entity, public virtual void ClearLocalEvents() { - if (_localEvents == null) - { - return; - } - - _localEvents.Clear(); + _localEvents?.Clear(); } public virtual void ClearDistributedEvents() { - if (_distributedEvents == null) - { - return; - } - - _distributedEvents.Clear(); + _distributedEvents?.Clear(); } protected virtual void AddLocalEvent(object eventData) @@ -87,22 +77,12 @@ public abstract class BasicAggregateRoot : Entity, public virtual void ClearLocalEvents() { - if (_localEvents == null) - { - return; - } - - _localEvents.Clear(); + _localEvents?.Clear(); } public virtual void ClearDistributedEvents() { - if (_distributedEvents == null) - { - return; - } - - _distributedEvents.Clear(); + _distributedEvents?.Clear(); } protected virtual void AddLocalEvent(object eventData)