Browse Source

Add GetSetMethod condition before SetValue.

Resolve #2444
pull/2447/head
maliming 7 years ago
parent
commit
3d1ee5ec52
  1. 6
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs
  2. 2
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs

6
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)); 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);
} }
} }

2
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs

@ -94,7 +94,7 @@ namespace Volo.Abp.Domain.Entities
nameof(entity.Id) nameof(entity.Id)
); );
if (idProperty == null) if (idProperty == null || idProperty.GetSetMethod(true) == null)
{ {
return; return;
} }

Loading…
Cancel
Save