From 83e60ad446983589e47ba65e65174c9473fa584e Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 24 May 2017 13:43:08 +0800 Subject: [PATCH] - --- OrmTest/UnitTest/Insert.cs | 4 ++++ SqlSugar/Realization/SqlServer/SqlServerProvider.cs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OrmTest/UnitTest/Insert.cs b/OrmTest/UnitTest/Insert.cs index f082fc9af..b85e73018 100644 --- a/OrmTest/UnitTest/Insert.cs +++ b/OrmTest/UnitTest/Insert.cs @@ -35,6 +35,7 @@ namespace OrmTest.UnitTest }, t1.Key, t1.Value, "Insert t1 error" ); + //Insert reutrn Command Count var t2 = db.Insertable(insertObj).ExecuteCommand(); @@ -114,6 +115,9 @@ INSERT INTO [Student] insertObjs.Add(new Student() { Name = "name" + i }); } var s9 = db.Insertable(insertObjs.ToArray()).InsertColumns(it => new { it.Name }).With(SqlWith.UpdLock).ToSql(); + + insertObj.Name = null; + var t10 = db.Insertable(insertObj).ExecuteCommand(); } public SqlSugarClient GetInstance() diff --git a/SqlSugar/Realization/SqlServer/SqlServerProvider.cs b/SqlSugar/Realization/SqlServer/SqlServerProvider.cs index 08063ce34..b880fdd2e 100644 --- a/SqlSugar/Realization/SqlServer/SqlServerProvider.cs +++ b/SqlSugar/Realization/SqlServer/SqlServerProvider.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; @@ -79,6 +80,7 @@ namespace SqlSugar int i = 0; foreach (var par in pars) { + if (par.Value == null) par.Value = DBNull.Value; var p = new SqlParameter(); p.ParameterName = par.ParameterName; p.UdtTypeName = par.UdtTypeName;