如何在异步csharp-SQLite包装器中使用事务?

Dab*_*uto 0 c# sqlite

我在C#项目中使用csharp-SQLite包装器。

以前,我使用相同的库,但是使用了同步功能而不是异步功能。

我可以使用BeginTransaction。该函数在异步调用中不存在。

如何使用异步调用启动和提交事务?

Dab*_*uto 5

我在Stackoverflow中找到了它。该函数是RunInTransactionAsync:

await MyDatabaseManager.Connection.RunInTransactionAsync((SQLiteConnection connection) =>
{
  foreach (Hotel _hotel in listUpdates)
  {
    result = connection.Update(_hotel);

    if (result == 0)
    {
      connection.Insert(_hotel);
    }
  }
});
Run Code Online (Sandbox Code Playgroud)