I have the following script:
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted },EnterpriseServicesInteropOption.Automatic)) { using (DataContext db = new DataContext()) { db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { bool outcome = InvokeInTransaction<string, object>(inputDict, out outputDict); db.Transaction.Commit(); } catch (Exception ex) { response.Outcome = BusinessEntityResponse.SystemError; db.Transaction.Rollback(); } } }
Inside the InvokeInTransaction call, there are a number of calls made to the LTS repository to perform various data changes. The problem is that inside the repository there is still
using (var db = new DataContext())
Inside is a save code. Checking the context in the repository shows Transaction = null, and I suspect that the "internal" context is not aware of the Ambient transaction. It can be done? I understand that EF manages this under the covers, and the limitation is that the repository code cannot be changed. Any help?
source share