Browse Source

Merge pull request #2447 from abpframework/maliming/TryToSetTenantId

Add GetSetMethod condition before SetValue.
pull/2483/head
Halil İbrahim Kalkan 7 years ago
committed by GitHub
parent
commit
b1b96ebc1f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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));
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)
);
if (idProperty == null)
if (idProperty == null || idProperty.GetSetMethod(true) == null)
{
return;
}

Loading…
Cancel
Save