diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs index f79f0a60a2..a708ecc10d 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Reflection; namespace Volo.Abp.Reflection @@ -33,8 +34,8 @@ namespace Volo.Abp.Reflection return true; } - if (includeNullables && - type.IsGenericType && + if (includeNullables && + type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) { return IsPrimitiveExtendedInternal(type.GenericTypeArguments[0], includeEnums); @@ -43,6 +44,16 @@ namespace Volo.Abp.Reflection return false; } + public static Type GetFirstGenericArgumentIfNullable(this Type t) + { + if (t.GetGenericArguments().Length > 0 && t.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return t.GetGenericArguments().FirstOrDefault(); + } + + return t; + } + private static bool IsPrimitiveExtendedInternal(Type type, bool includeEnums) { if (type.IsPrimitive) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs index 1c48fffc53..b50afd3b2a 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs @@ -13,6 +13,7 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities; using Volo.Abp.Json; using Volo.Abp.MultiTenancy; +using Volo.Abp.Reflection; using Volo.Abp.Timing; using Volo.Abp.Uow; @@ -170,7 +171,7 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory NewValue = isDeleted ? null : JsonSerializer.Serialize(propertyEntry.CurrentValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), OriginalValue = isCreated ? null : JsonSerializer.Serialize(propertyEntry.OriginalValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), PropertyName = property.Name, - PropertyTypeFullName = property.ClrType.FullName, + PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName, TenantId = GetTenantId(entityEntry.Entity) }); } @@ -311,7 +312,7 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory NewValue = JsonSerializer.Serialize(propertyEntry.CurrentValue), OriginalValue = JsonSerializer.Serialize(propertyEntry.OriginalValue), PropertyName = property.Name, - PropertyTypeFullName = property.ClrType.FullName + PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName }); }