- 优化 SetSource 机制不更新主键字段;

This commit is contained in:
28810
2020-08-10 18:44:05 +08:00
parent 3018fc8b2b
commit 8da3c16c40
5 changed files with 187 additions and 17 deletions

View File

@ -179,7 +179,7 @@ namespace FreeSql.Tests.DataAnnotations
item.title = "testtitle_update";
item.testfield2 = 0;
sql = g.mysql.Update<TestCanInsert>().SetSource(item).ToSql().Replace("\r\n", "");
Assert.Equal($"UPDATE `TestCanInsert` SET `id` = ?p_0, `title` = ?p_1, `testfield1` = ?p_2 WHERE (`id` = '{item.id}')", sql);
Assert.Equal($"UPDATE `TestCanInsert` SET `title` = ?p_0, `testfield1` = ?p_1 WHERE (`id` = '{item.id}')", sql);
Assert.Equal(1, g.mysql.Update<TestCanInsert>().SetSource(item).ExecuteAffrows());
find = g.mysql.Select<TestCanInsert>().Where(a => a.id == item.id).First();