mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 IUpdate.SetSourceIgnore 方法,可实现忽略 null 属性的更新;
This commit is contained in:
@ -66,6 +66,20 @@ namespace FreeSql.Tests.Odbc.SqlServer
|
||||
public string xx { get; set; }
|
||||
}
|
||||
[Fact]
|
||||
public void SetSourceIgnore()
|
||||
{
|
||||
Assert.Equal("UPDATE [tssi01] SET [tint] = 10 WHERE ([id] = '00000000-0000-0000-0000-000000000000')",
|
||||
g.sqlserver.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, a.TypeGuid }).ToSql().Replace("\r\n", "");
|
||||
|
Reference in New Issue
Block a user