From 66e6e549a136c9469942f48aaa413857208549cd Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Mon, 25 Nov 2019 13:51:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E5=88=97=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E7=BA=A6=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Falcon.ModelSP/DataExtend.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Falcon.ModelSP/DataExtend.cs b/Falcon.ModelSP/DataExtend.cs index 9389bea..9e1ca78 100644 --- a/Falcon.ModelSP/DataExtend.cs +++ b/Falcon.ModelSP/DataExtend.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; - +using System; namespace Falcon.ModelSP { @@ -109,7 +109,7 @@ namespace Falcon.ModelSP for(var i = 0;i < columnSchema.Count;i++) { var name = dr.GetName(i); var value = dr.IsDBNull(i) ? null : dr.GetValue(i); - var pi = typeof(TR).GetProperty(name); + var pi = getProperty(name); if(pi == null || !pi.CanWrite) continue; pi.SetValue(item,value); @@ -120,6 +120,17 @@ namespace Falcon.ModelSP return result; } } - + /// + /// 忽略大小写获取类型的属性 + /// + private static PropertyInfo getProperty(string name) { + var type = typeof(T); + foreach(var item in type.GetProperties()) { + if(item.Name.ToLower() == name.ToLower()) { + return item; + } + } + return null; + } } }