From 3d1ee5ec52d692bd94f3b915386cb3e58cedee00 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 23 Dec 2019 16:18:49 +0800 Subject: [PATCH] Add GetSetMethod condition before SetValue. Resolve #2444 --- .../Volo/Abp/Application/Services/CrudAppService.cs | 6 ++++-- .../Volo/Abp/Domain/Entities/EntityHelper.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs index 237e89aa53..4134b59a4c 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs @@ -321,10 +321,12 @@ namespace Volo.Abp.Application.Services var propertyInfo = entity.GetType().GetProperty(nameof(IMultiTenant.TenantId)); - if (propertyInfo != null && propertyInfo.GetSetMethod() != null) + if (propertyInfo == null || propertyInfo.GetSetMethod(true) == null) { - propertyInfo.SetValue(entity, tenantId, null); + return; } + + propertyInfo.SetValue(entity, tenantId); } } diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs index e72a92c14a..92ebdd4568 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs @@ -94,7 +94,7 @@ namespace Volo.Abp.Domain.Entities nameof(entity.Id) ); - if (idProperty == null) + if (idProperty == null || idProperty.GetSetMethod(true) == null) { return; }