Skip to content

Instantly share code, notes, and snippets.

@viktors-telle
Created June 13, 2020 14:10
Show Gist options
  • Save viktors-telle/6c4042a24e5cd5a1120a481bfaf16c2a to your computer and use it in GitHub Desktop.
Save viktors-telle/6c4042a24e5cd5a1120a481bfaf16c2a to your computer and use it in GitHub Desktop.
public async Task ExecuteTransaction(Func<Task> action)
{
using var session = await client.StartSessionAsync();
session.StartTransaction();
try
{
await action();
await session.CommitTransactionAsync();
}
catch (Exception)
{
await session.AbortTransactionAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment