Created
June 13, 2020 14:10
-
-
Save viktors-telle/6c4042a24e5cd5a1120a481bfaf16c2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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