Mar 24, 2021
That kinda depends the way you are using it.
Assuming you are injecting an IDbConnection (or some wrapper interface) into your handlers, the same way we are injecting the Entity Framework DbContext, just do the same in this pipeline and begin and commit a transaction in a similar way to what we did in the article (await using var tx = await connection.BeginTransactionAsync(ct); await next(cmd, ct); await tx.CommitAsync(ct)).
If, for some reason, you are initializing your connections inside the handlers, you need to use a TransactionScope instead.