- 增加 IUpdate.SetSourceIgnore 方法,可实现忽略 null 属性的更新;

This commit is contained in:
28810
2020-05-22 18:20:28 +08:00
parent 97d8c39e1a
commit 99f0dd7391
19 changed files with 246 additions and 21 deletions

View File

@ -93,6 +93,20 @@ namespace FreeSql.Tests.Odbc.MySql
public string xx { get; set; }
}
[Fact]
public void SetSourceIgnore()
{
Assert.Equal("UPDATE `tssi01` SET `tint` = 10 WHERE (`id` = '00000000-0000-0000-0000-000000000000')",
g.mysql.Update<tssi01>().NoneParameter()
.SetSourceIgnore(new tssi01 { id = Guid.Empty, tint = 10 }, col => col == null).ToSql().Replace("\r\n", ""));
}
public class tssi01
{
[Column(CanUpdate = false)]
public Guid id { get; set; }
public int tint { get; set; }
public string title { get; set; }
}
[Fact]
public void IgnoreColumns()
{
var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql().Replace("\r\n", "");