Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created April 7, 2015 15:42
Show Gist options
  • Save jbogard/086cbaddc5333b99ed75 to your computer and use it in GitHub Desktop.
Save jbogard/086cbaddc5333b99ed75 to your computer and use it in GitHub Desktop.
public TResult Send<TResult>(IRequest<TResult> message)
{
var context = Container.GetInstance<MyContext>();
var mediator = Container.GetInstance<IMediator>();
DbContextTransaction txn = null;
TResult result;
try
{
txn = context.Database.BeginTransaction();
result = mediator.Send(message);
txn.Commit();
}
catch (Exception)
{
txn?.Rollback();
throw;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment