Browse Source

UpdateColumns SqlFunc.IIF SqlFunc.IF BUG

pull/12/MERGE
610262374@qq.com 6 years ago
parent
commit
8fd8deb4c5
  1. 12
      Src/Asp.Net/SqlServerTest/Demos/2_Update.cs
  2. 4
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs
  3. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

12
Src/Asp.Net/SqlServerTest/Demos/2_Update.cs

@ -93,6 +93,18 @@ namespace OrmTest.Demo
dtList.Add(dt);
dtList.Add(dt2);
var t666 = db.Updateable(dtList).AS("student").WhereColumns("id").With(SqlWith.UpdLock).ExecuteCommand();
var t20 = db.Updateable<Student>().UpdateColumns(p => new Student()
{
SchoolId = SqlFunc.IIF(p.Id == 1, 2, 3)
}).Where(p => p.Id == 10000).ExecuteCommand();
var t21= db.Updateable<Student>().UpdateColumns(p => new Student()
{
SchoolId = SqlFunc.IF(p.Id==1).Return(1).End(p.Id)
}).Where(p => p.Id == 10000).ExecuteCommand();
}
}
}

4
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs

@ -75,6 +75,10 @@ namespace SqlSugar
public virtual string GetNoTranslationColumnName(string name)
{
if (name.Contains("="))
{
name=name.Split('=').First();
}
if (!name.Contains(SqlTranslationLeft)) return name;
return name == null ? string.Empty : Regex.Match(name, @".*" + "\\" + SqlTranslationLeft + "(.*?)" + "\\" + SqlTranslationRight + "").Groups[1].Value;
}

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -59,7 +59,7 @@ namespace SqlSugar
{
CaseWhenResolve caseResole = new CaseWhenResolve(express, this.Context, parameter.OppsiteExpression);
var appendSql = caseResole.GetSql();
if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle))
if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle,ResolveExpressType.Update))
{
parameter.BaseParameter.CommonTempData = appendSql;
}

Loading…
Cancel
Save