Browse Source

Update exp to sql

pull/2/head
skx 4 years ago
parent
commit
6587e3a155
  1. 8
      Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs
  2. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

8
Src/Asp.Net/SqlServerTest/UnitTest/Updateable.cs

@ -94,6 +94,14 @@ namespace OrmTest
.SetColumns(it => new Order { Name = "a", CreateTime = DateTime.Now })
.SetColumns(it => new Order() { Price = 1 }).Where(it => it.Id == 1).ExecuteCommand();
Db.Updateable<Order>()
.SetColumns(it => new Order { Name= it.Id>0 ?"1":"2", CreateTime = DateTime.Now })
.Where(it => it.Id == 1).ExecuteCommand();
Db.Updateable<Order>()
.SetColumns(it => new Order { Name = SqlFunc.IsNull(it.Name,"a")+"b", CreateTime = DateTime.Now })
.Where(it => it.Id == 1).ExecuteCommand();
Db.CodeFirst.InitTables<Unitbluecopy>();
Db.Insertable(new Unitbluecopy()).UseSqlServer().ExecuteBlueCopy();
}

4
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)

Loading…
Cancel
Save