补充 开放 IUpdate UpdateColumns 方法功能;

现实更新实体时,只更新指定的列(与 IgnoreColumns 对应);
This commit is contained in:
28810
2019-04-15 17:54:45 +08:00
parent e5ba4b1974
commit 9245909d79
7 changed files with 61 additions and 0 deletions

View File

@ -60,6 +60,11 @@ namespace FreeSql.Tests.SqlServer {
Assert.Equal("UPDATE [tb_topic] SET [Title] = @p_0 WHERE ([Id] = 1)", sql);
}
[Fact]
public void UpdateColumns() {
var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).UpdateColumns(a => a.Title).ToSql().Replace("\r\n", "");
Assert.Equal("UPDATE [tb_topic] SET [Title] = @p_0 WHERE ([Id] = 1)", sql);
}
[Fact]
public void Set() {
var sql = update.Where(a => a.Id == 1).Set(a => a.Title, "newtitle").ToSql().Replace("\r\n", "");
Assert.Equal("UPDATE [tb_topic] SET [Title] = @p_0 WHERE ([Id] = 1)", sql);