From 4ba7e627406f4e73ae547c509e3c2208be6373d5 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 20 Apr 2019 13:48:26 +0800 Subject: [PATCH] Update BUG --- Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs | 45 +++++++++++++++++++ .../UpdateProvider/UpdateableProvider.cs | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs b/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs index e3dae19aa..724315925 100644 --- a/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs +++ b/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs @@ -104,9 +104,54 @@ namespace OrmTest.BugTest testa.Col3 = "444"; DB.Saveable(testa).ExecuteCommand(); + + + Guid newCarTypePictureId = Guid.Empty; + Guid carTypePictureId = Guid.Empty; + DB.CodeFirst.InitTables(typeof(Picture)); + DB.Updateable() + .UpdateColumns(p => p.Value == SqlFunc.Subqueryable() + .Where(pp => pp.ID == newCarTypePictureId) + .Select(pp => pp.Value)) + .Where(p => p.ID == carTypePictureId) + .ExecuteCommand(); + DB.Updateable() + .UpdateColumns(p => p.Value == SqlFunc.Subqueryable() + .Select(pp => pp.Value)) + + .Where(p => p.ID == carTypePictureId).ExecuteCommand(); } } + public partial class Picture + { + public Picture() + { + + + } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true)] + public Guid ID { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:False + /// + public byte Type { get; set; } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + public string Value { get; set; } + + } /// ///用户信息表 /// diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index e3fedef1d..0d49a9e4a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -210,7 +210,7 @@ namespace SqlSugar Check.Exception(!binaryExp.NodeType.IsIn(ExpressionType.Equal), "No support {0}", columns.ToString()); Check.Exception(!(binaryExp.Left is MemberExpression) && !(binaryExp.Left is UnaryExpression), "No support {0}", columns.ToString()); Check.Exception(ExpressionTool.IsConstExpression(binaryExp.Left as MemberExpression), "No support {0}", columns.ToString()); - var expResult = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.WhereSingle).GetResultString().Replace("))", ") )").Replace("((", "( (").Trim().TrimStart('(').TrimEnd(')'); + var expResult = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.WhereSingle).GetResultString().Replace(")", " )").Replace("(", "( ").Trim().TrimStart('(').TrimEnd(')'); string key = SqlBuilder.GetNoTranslationColumnName(expResult); UpdateBuilder.SetValues.Add(new KeyValuePair(SqlBuilder.GetTranslationColumnName(key), expResult)); this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase) || SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();