Update exp to sql

This commit is contained in:
610262374@qq.com 2019-06-18 18:30:41 +08:00
parent 997c61735a
commit 9ac7f1b2bc
2 changed files with 30 additions and 0 deletions

View File

@ -54,8 +54,37 @@ namespace OrmTest
UValidate.Check(sql.Key, @"UPDATE [Diary] SET
[TypeID] = @Const0 WHERE ( [ID] = @ID1 )", "Updateable");
sql = Db.Updateable<UnitDiary>().SetColumns(it => new UnitDiary()
{
TypeID = saveDiary.TypeID,
}).Where(it => it.ID == saveDiary.ID).ToSql();
UValidate.Check(sql.Key, @"UPDATE [Diary] SET
[TypeID] = @Const0 WHERE ( [ID] = @ID1 )", "Updateable");
sql=Db.Updateable<NullTest>().SetColumns(it => new NullTest()
{
p = true
}).Where(it => it.id == 1).ToSql();
UValidate.Check(sql.Key, @"UPDATE [NullTest] SET
[p] = @Const0 WHERE ( [id] = @id1 )", "Updateable");
sql = Db.Updateable<NullTest>().SetColumns(it => new NullTest()
{
p2 = true
}).Where(it => it.id == 1).ToSql();
UValidate.Check(sql.Key, @"UPDATE [NullTest] SET
[p2] = @Const0 WHERE ( [id] = @id1 )", "Updateable");
}
}
public class NullTest
{
public int id { get; set; }
public bool? p { get; set; }
public bool p2 { get; set; }
}
public class UnitSaveDiary
{
public int ID { get; set; }

View File

@ -109,6 +109,7 @@ namespace SqlSugar
}
else if (IsConst(item)&&IsConvert(item)&&UtilMethods.IsNullable(item.Type) && UtilMethods.GetUnderType(item.Type)==UtilConstants.BoolType)
{
item = (item as UnaryExpression).Operand;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, GetNewExpressionValue(item)));
}
else if (IsConst(item))