I'm try to use TransactionScope with generated data context like this:
Code: Select all
using(var scope = new TransactionScope())
{
using(var context = new MyDataContext())
{
context.Tests.InsertOnSubmit(new Test());
context.SubmitChanges();
scope.Complete();
}
}
For example this code block is working:
Code: Select all
using (var context = new MyDataContext())
{
try
{
context.Tests.InsertOnSubmit(new Test());
context.Connection.Open();
context.Transaction = context.Connection.BeginTransaction();
context.SubmitChanges();
context.Transaction.Commit();
}
catch (Exception)
{
context.Transaction.Rollback();
throw;
}
}