From 76fd0f1236dbdb01f9261383a4ef9374d70a82ad Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 3 Aug 2022 01:29:35 +0800 Subject: [PATCH] Add unit test --- .../SqlServerTest/UnitTest/UQueryable2.cs | 26 +++++++++++++++++++ .../SqlBuilder/SqlServerUpdateBuilder.cs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs index e5e37553b..35b872945 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs @@ -292,6 +292,32 @@ namespace OrmTest { throw new Exception("unit error"); } + + var sql15=db.Updateable(new List() + { + new UintAinstringHAHA(){ id="1", xame="a" }, + new UintAinstringHAHA(){ id="2", xame="a" } + }).ToSql().Key; + db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.Insertable(new List() + { + new UintAinstringHAHA(){ id="1", xame="a" }, + new UintAinstringHAHA(){ id="2", xame="a" } + }).ExecuteCommand(); + var rows=db.Ado.ExecuteCommand(sql15); + if (sql15.ToLower().Contains("n'") || rows != 2) + { + throw new Exception("unit error"); + } + } + + public class UintAinstringHAHA + { + [SugarColumn(IsPrimaryKey =true,SqlParameterDbType =System.Data.DbType.AnsiString)] + public string id { get; set; } + [SugarColumn(SqlParameterDbType = System.Data.DbType.AnsiString)] + public string xame { get; set; } } public class VUOrder { diff --git a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerUpdateBuilder.cs index b7c6d8e86..4853d2384 100644 --- a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerUpdateBuilder.cs @@ -76,7 +76,7 @@ namespace SqlSugar if (it.SqlParameterDbType!=null&&it.SqlParameterDbType.Equals(System.Data.DbType.AnsiString)) { var value = FormatValue(it.Value); - if (value is string&&value.ObjToString().Contains("N'")) + if (value is string&&value.ObjToString().StartsWith("N'")) { return value.ObjToString().TrimStart('N'); }