This question is locked. New answers and comments are not allowed.
When i was using NHibernate and Linq to SQL I've created database fixture, which rollbacks database changes
after each test.
public class DatabaseFixture : IDisposable
{
private readonly TransactionScope transactionScope;
protected DatabaseFixture()
{
transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
}
#region IDisposable Members
public void Dispose()
{
transactionScope.Dispose();
}
#endregion
}
But now it doesn't rollbacks changes made on object scope transaction commit. Any ideas how to get it work =)
5 Answers, 1 is accepted
0
Hi Alexey,
You should not use the scope.Transaction, you have to change the transaction properties of your database so that we integrate us into system.transactions:
database.Properties.TransactionProvider = TransactionProvider.TransactionScope;
Greetings,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You should not use the scope.Transaction, you have to change the transaction properties of your database so that we integrate us into system.transactions:
database.Properties.TransactionProvider = TransactionProvider.TransactionScope;
Greetings,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexey
Top achievements
Rank 2
answered on 10 Nov 2008, 01:29 PM
But if want to use scope transaction. How can i implement such database fixture (It should rollback any changes within database made during the test)?
0
Hi Alexey,
You can only do it in the same way. just set the property at Database and use your code as it is.
Kind regards,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You can only do it in the same way. just set the property at Database and use your code as it is.
Kind regards,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexey
Top achievements
Rank 2
answered on 10 Nov 2008, 03:17 PM
Also Open Access Transaction has Level property which determinate nesting level. But I don't understand how we can create nested transactions? There is nothing said about it in documentation.
0
Hello Alexey,
Nested transactions are not supported at the moment. The level can only be 0 and 1.
Best wishes,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Nested transactions are not supported at the moment. The level can only be 0 and 1.
Best wishes,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.