From 291f2fe2d88c5092d8bbba5bb6f55f78cb482d30 Mon Sep 17 00:00:00 2001 From: "610262374@qq.com" <610262374@qq.com> Date: Fri, 12 Oct 2018 16:20:59 +0800 Subject: [PATCH] Insertable Updateable Dictionary BUG --- Src/Asp.Net/SqlServerTest/Config.cs | 6 +++--- Src/Asp.Net/SqlServerTest/Demos/2_Update.cs | 3 ++- Src/Asp.Net/SqlServerTest/Demos/3_Insert.cs | 1 + .../Abstract/InsertableProvider/InsertableProvider.cs | 2 +- .../SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Src/Asp.Net/SqlServerTest/Config.cs b/Src/Asp.Net/SqlServerTest/Config.cs index 7d87d0ee6..43f3df924 100644 --- a/Src/Asp.Net/SqlServerTest/Config.cs +++ b/Src/Asp.Net/SqlServerTest/Config.cs @@ -8,8 +8,8 @@ namespace OrmTest { public class Config { - public static string ConnectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugar4XTest"; - public static string ConnectionString2 = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST"; - public static string ConnectionString3 = "server=.;uid=sa;pwd=sasa;database=sqlsugar4xtest"; + public static string ConnectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SqlSugar4XTest"; + public static string ConnectionString2 = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST"; + public static string ConnectionString3 = "server=.;uid=sa;pwd=@jhl85661501;database=sqlsugar4xtest"; } } diff --git a/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs b/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs index 0145ce2e4..e8c63fdbe 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs @@ -74,7 +74,8 @@ namespace OrmTest.Demo var dt = new Dictionary(); dt.Add("id", 1); - dt.Add("name", "1"); + dt.Add("name", null); + dt.Add("createTime", DateTime.Now); var t66 = db.Updateable(dt).AS("student").With(SqlWith.UpdLock).ExecuteCommand(); } } diff --git a/Src/Asp.Net/SqlServerTest/Demos/3_Insert.cs b/Src/Asp.Net/SqlServerTest/Demos/3_Insert.cs index 8da1051bb..4bcab57e8 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/3_Insert.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/3_Insert.cs @@ -63,6 +63,7 @@ namespace OrmTest.Demo var dt = new Dictionary(); dt.Add("name", "1"); + dt.Add("CreateTime", null); var t66 = db.Insertable(dt).AS("student").ExecuteReturnIdentity(); } } diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index e8594d9b5..0d5543097 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -289,7 +289,7 @@ namespace SqlSugar Value = column.Value, DbColumnName = column.Key, PropertyName = column.Key, - PropertyType = UtilMethods.GetUnderType(column.Value.GetType()), + PropertyType = column.Value == null? DBNull.Value.GetType(): UtilMethods.GetUnderType(column.Value.GetType()), TableId = i }; if (columnInfo.PropertyType.IsEnum()) diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index 2e14edc01..13e3eb167 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -280,7 +280,7 @@ namespace SqlSugar Value = column.Value, DbColumnName =column.Key, PropertyName = column.Key, - PropertyType = UtilMethods.GetUnderType(column.Value.GetType()), + PropertyType = column.Value==null?DBNull.Value.GetType():UtilMethods.GetUnderType(column.Value.GetType()), TableId = i }; if (columnInfo.PropertyType.IsEnum())