From de5f469ed0a5ba2c236ab5d06340bd1f37837549 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 30 Jul 2020 17:55:22 +0800 Subject: [PATCH] Small refactoring. --- .../Volo/Abp/EntityFrameworkCore/AbpDbContext.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 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 178bab27a9..d63a93f8dd 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -314,9 +314,17 @@ namespace Volo.Abp.EntityFrameworkCore continue; } - var entryProperty = entry.Property(property.Name); var entityProperty = entity.GetProperty(property.Name); - entryProperty.CurrentValue = Convert.ChangeType(entityProperty, entryProperty.Metadata.ClrType); + if (entityProperty == null) + { + continue; + } + + var entryProperty = entry.Property(property.Name); + + entryProperty.CurrentValue = entryProperty.Metadata.ClrType == entityProperty.GetType() + ? entityProperty + : Convert.ChangeType(entityProperty, entryProperty.Metadata.ClrType); } }