Browse Source

Add unit test

SqlSugar5
sunkaixuan 2 years ago
parent
commit
76fd0f1236
  1. 26
      Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs
  2. 2
      Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerUpdateBuilder.cs

26
Src/Asp.Net/SqlServerTest/UnitTest/UQueryable2.cs

@ -292,6 +292,32 @@ namespace OrmTest
{
throw new Exception("unit error");
}
var sql15=db.Updateable(new List<UintAinstringHAHA>()
{
new UintAinstringHAHA(){ id="1", xame="a" },
new UintAinstringHAHA(){ id="2", xame="a" }
}).ToSql().Key;
db.CodeFirst.InitTables<UintAinstringHAHA>();
db.DbMaintenance.TruncateTable<UintAinstringHAHA>();
db.Insertable(new List<UintAinstringHAHA>()
{
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
{

2
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');
}

Loading…
Cancel
Save