From 230821750b7c54d296652f2f9d962efa63791281 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 30 Apr 2019 11:19:09 +0300 Subject: [PATCH] Check for null. --- .../Events/EntityChangeEventHelper.cs | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs index 06554d451e..c9219feffc 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/EntityChangeEventHelper.cs @@ -65,12 +65,16 @@ namespace Volo.Abp.Domain.Entities.Events false ); - await TriggerEventWithEntity( - DistributedEventBus, - typeof(EntityCreatedEto<>), - EntityToEtoMapper.Map(entity), - false - ); + var eto = EntityToEtoMapper.Map(entity); + if (eto != null) + { + await TriggerEventWithEntity( + DistributedEventBus, + typeof(EntityCreatedEto<>), + eto, + false + ); + } } public virtual async Task TriggerEntityUpdatingEventAsync(object entity) @@ -92,12 +96,16 @@ namespace Volo.Abp.Domain.Entities.Events false ); - await TriggerEventWithEntity( - DistributedEventBus, - typeof(EntityUpdatedEto<>), - EntityToEtoMapper.Map(entity), - false - ); + var eto = EntityToEtoMapper.Map(entity); + if (eto != null) + { + await TriggerEventWithEntity( + DistributedEventBus, + typeof(EntityUpdatedEto<>), + eto, + false + ); + } } public virtual async Task TriggerEntityDeletingEventAsync(object entity) @@ -119,12 +127,16 @@ namespace Volo.Abp.Domain.Entities.Events false ); - await TriggerEventWithEntity( - DistributedEventBus, - typeof(EntityDeletedEto<>), - EntityToEtoMapper.Map(entity), - false - ); + var eto = EntityToEtoMapper.Map(entity); + if (eto != null) + { + await TriggerEventWithEntity( + DistributedEventBus, + typeof(EntityDeletedEto<>), + EntityToEtoMapper.Map(entity), + false + ); + } } protected virtual async Task TriggerEventsInternalAsync(EntityChangeReport changeReport)