Browse Source

Use TypeHelper.IsPrimitiveExtended.

pull/4920/head
maliming 6 years ago
parent
commit
ad5bec023b
  1. 15
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs

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

Loading…
Cancel
Save