当使用最新版本的 System.Data.SQLite nuget 包创建一个简单的 SQLite 事务时,我注意到 SQLiteConnection.BeginTransaction() 方法的智能感知描述包含“[deprecated]”并且以单词 OBSOLETE(在全部大写,可怕!)。但是,没有提到开始交易的新方法是什么。
我仍然可以很好地调用该方法,而且 IDE 中甚至没有警告,但是是否有一种我不知道的完成以下操作的新方法?
using (var conn = new SQLiteConnection(dbConnectionString))
{
conn.Open();
using (var trans = conn.BeginTransaction())
{
using (var cmd = new SQLiteCommand("some sql statement here", conn, trans))
{
cmd.ExecuteNonQuery();
}
trans.Commit();
}
}
最佳答案
好吧,根据他们的源代码,只有带有参数 bool deferredLock
的重载是过时的。您使用的方法不是:
来源:http://system.data.sqlite.org/index.html/artifact/5d691bfc46d3c324
关于c# - SQLiteConnection.BeginTransaction() 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50656018/