From ad5bec023b560386d6da285954a5bd06d58a4d14 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 30 Jul 2020 18:39:17 +0800 Subject: [PATCH] Use TypeHelper.IsPrimitiveExtended. --- .../Volo/Abp/EntityFrameworkCore/AbpDbContext.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index d63a93f8dd..5b8e9e6678 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; +using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -322,9 +323,17 @@ namespace Volo.Abp.EntityFrameworkCore var entryProperty = entry.Property(property.Name); - entryProperty.CurrentValue = entryProperty.Metadata.ClrType == entityProperty.GetType() - ? entityProperty - : Convert.ChangeType(entityProperty, entryProperty.Metadata.ClrType); + if (entryProperty.Metadata.ClrType == entityProperty.GetType()) + { + entryProperty.CurrentValue = entityProperty; + } + else + { + if (TypeHelper.IsPrimitiveExtended(entryProperty.Metadata.ClrType, includeEnums: true)) + { + entryProperty.CurrentValue = Convert.ChangeType(entityProperty, entryProperty.Metadata.ClrType, CultureInfo.InvariantCulture); + } + } } }