Browse Source

Update BUG

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
4ba7e62740
  1. 45
      Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs
  2. 2
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

45
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<Picture>()
.UpdateColumns(p => p.Value == SqlFunc.Subqueryable<Picture>()
.Where(pp => pp.ID == newCarTypePictureId)
.Select(pp => pp.Value))
.Where(p => p.ID == carTypePictureId)
.ExecuteCommand();
DB.Updateable<Picture>()
.UpdateColumns(p => p.Value == SqlFunc.Subqueryable<Picture>()
.Select(pp => pp.Value))
.Where(p => p.ID == carTypePictureId).ExecuteCommand();
}
}
public partial class Picture
{
public Picture()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public Guid ID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
public byte Type { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
public string Value { get; set; }
}
///<summary>
///用户信息表
///</summary>

2
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<string, string>(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();

Loading…
Cancel
Save