https://github.com/brianium/transaction-scope-test
Testing multiple database connections with SQL Server 2008, NHibernate, and TransactionScope
https://github.com/brianium/transaction-scope-test
Last synced: about 1 year ago
JSON representation
Testing multiple database connections with SQL Server 2008, NHibernate, and TransactionScope
- Host: GitHub
- URL: https://github.com/brianium/transaction-scope-test
- Owner: brianium
- Created: 2014-01-23T21:22:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-24T02:36:21.000Z (over 12 years ago)
- Last Synced: 2025-03-18T05:56:27.733Z (about 1 year ago)
- Language: C#
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Using NHibernate with System.Transactions.TransactionScope
==========================================================
This repo demonstrates how System.Transactions.TransactionScope works with NHibernate transactions, particularly
transactions involving multiple databases.
Creating a new transaction scope creates an "ambient" transaction meaning *all* ADO operations on the same thread will
participate in that same ambient transaction.
This repo contains a test suite demonstrating it's use and proving it works as expected with NHibernate transactions, showing NHibernate
transactions will automatically enlist in the ambient transaction.
Requirements
------------
* A SQLExpress instance or equivalent - these tests were built on a Sql Server 2008 R2 express instance and the connection strings reflect that
* A database called `ProductDatabase`
* A database called `OrderDatabase`
Setting up databases
--------------------
After building the project run `bin\migrateup.bat` to create tables on both databases. You can run `bin\migratedown.bat` to remove the tables.
Running the tests
-----------------
The tests demonstrate saving on both databases using an ambient transaction created using `new System.Transactions.TransactionScope()`
All tests were written in a single `Test` class in the `TransactionScopeTest.SessionTest` project in the `tests` directory.
These tests should prove that `TransactionScope` can be used to acheive transactional behavior between multiple NHibernate sessions, each connected
to a different database.