You are right escalating the Database Transaction to the Distributed Transaction Coordinator is always not wanted because it is hard to setup and it is costly operation performance wise.
With Telerik OpenAccess ORM you can achieve this relatively easy.
The most simple way is to guarantee that all of your repository instances use one and the same OpenAccessContext instance and control the Database Transaction outside the repositories:
(var dbContext =
var supplierRepository =
var productsRepository =
var supplier =
var p =
Supplier = supplier
"Gets a random error for some reason"
//commit the transaction
//If an exception occurs the transaction will be rolled back at this point;
To get this approach working you should:
1. Inject single instance of the context to all repositories
2. Replace all SaveChanges() calls in you repository classes to FlushChanges(). This will persist all changes to the Database but will not commit the transaction. It will throw an exception if you have data integrity problem and the transaction will be rolled back when you leave the using statement or when you call the ClearChanges() method manually;
3. Call SaveChanges only once when you are ready with all operations.
4. Always use the context in using statement to guarantee that if an exception is thrown the opened transaction will be rolled back or wrap you logic in try-catch-finally block and call the ClearChanges() where it is appropriate.
Please find attached a sample application.
You can read more about the transactions in OpenAccess ORM here
I hope this helps. Please do not hesitate to get back to us if you have any additional questions.
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.