With RepoDB I:
SqlServerBootstrap.Initialize();
using (var cnt = new SqlConnection(connectionString))
{
cnt.ExecuteNonQuery("DROP TABLE IF EXISTS example");
cnt.ExecuteNonQuery("CREATE TABLE example(Id int NOT NULL PRIMARY KEY, Data nvarchar(1));");
cnt.Merge("example", new { Id = 1, Data = "a" }); //Adds a row
cnt.ExecuteNonQuery("ALTER TABLE example ALTER COLUMN Data nvarchar(10);n ALTER TABLE example ADD Name nvarchar(10);");
cnt.Merge("example", new { Id = 1, Data = "Long_word", Name = "A_name" }); //Updates the same row
};
结果:Id = 1 Data = "Lo", Name = NULL
期望:Id = 1 Data = "Long_word", Name = "A_name"
所以RepoDB不知道我已经改变了两个列。是否有一个Flush()或Refresh(),所以我可以让RepoDB知道我已经做了改变?或者我是否可以在RepoDB中写入我做了哪些更改?
我在github上得到了一个快速的答案。
冲洗这些,它工作:
DbFieldCache.Flush(); // Remove all the cached DbField
FieldCache.Flush(); // Remove all the cached DbField
IdentityCache.Flush(); // Remove all the cached DbField
PrimaryCache.Flush(); // Remove all the cached DbField