Created
April 7, 2015 15:42
-
-
Save jbogard/086cbaddc5333b99ed75 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 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