Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From this discussion and a follow up with Jason he mentioned that transactions haven't been exposed to utilize them in mongo.
In order for transactions to work across repos there needs to only be one Mongo client in a given request, I've refactored all the type specific contexts to get the IMongoDb from the new IMongoDbContext which is a scoped service so there's only one instance per request.
Then I changed a couple methods in the Merge service to make changes inside transactions. You'll notice that the transaction is not aborted in our user code, this is because the transaction is disposable and if it's disposed before it's committed then it will be aborted, so if an exception is thrown between Begin and Commit then the changes made will be rolled back.
Feel free to suggest changes, I don't really love how I had to mock out and expose the transactions via the IMongoDbContext which also contains the IMongoDatabase, but I didn't really feel like making a separate service just for transactions, @jasonleenaylor let me know what you think there if we want to split those out.
This change is