From 6587e3a1557cfdcc3068053b5bb52f8b515cc177 Mon Sep 17 00:00:00 2001 From: skx <610262374@qq.com> Date: Sat, 16 Jan 2021 22:58:38 +0800 Subject: [PATCH] Update exp to sql --- Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs | 8 ++++++++ .../ResolveItems/MemberInitExpressionResolve.cs | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs index 43994aa61..3f693b026 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs @@ -93,6 +93,14 @@ namespace OrmTest Db.Updateable() .SetColumns(it => new Order { Name = "a", CreateTime = DateTime.Now }) .SetColumns(it => new Order() { Price = 1 }).Where(it => it.Id == 1).ExecuteCommand(); + + Db.Updateable() + .SetColumns(it => new Order { Name= it.Id>0 ?"1":"2", CreateTime = DateTime.Now }) + .Where(it => it.Id == 1).ExecuteCommand(); + + Db.Updateable() + .SetColumns(it => new Order { Name = SqlFunc.IsNull(it.Name,"a")+"b", CreateTime = DateTime.Now }) + .Where(it => it.Id == 1).ExecuteCommand(); Db.CodeFirst.InitTables(); Db.Insertable(new Unitbluecopy()).UseSqlServer().ExecuteBlueCopy(); diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs index 24e6a537e..fae2c88e3 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs @@ -154,6 +154,10 @@ namespace SqlSugar else if (item is BinaryExpression) { var result = GetNewExpressionValue(item); + if (result.HasValue()) + { + result = result.Replace(",", UtilConstants.ReplaceCommaKey); + } this.Context.Result.Append(base.Context.GetEqString(memberName, result)); } else if (item is MemberInitExpression)