Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EF 4.1 - Stored Procedure Not Inheriting Pending Transaction
- using (var tran = Connection.BeginTransaction(IsolationLevel.ReadUncommitted))
- {
- try
- {
- // Act.
- var result = controller.Create(something);
- // Assert.
- Assert.IsNotNull(result);
- }
- catch (Exception exc)
- {
- Assert.Fail(exc.Message);
- }
- finally
- {
- tran.Rollback();
- Connection.Close();
- }
- }
- var cmd = Database.Connection.CreateCommand();
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.CommandText = "exec dbo.MySP @SomeParam";
- cmd.Parameters.Add(new SqlParameter { Value = "test", ParameterName = "SomeParam" });
- using (var rdr = cmd.ExecuteReader()) <--- exception thrown here.
- {
- // code to read result sets.
- }
- using (new TransactionScope(TransactionScopeOption.Required,
- new TransactionOptions
- {
- IsolationLevel = IsolationLevel.ReadUncommitted
- }))
- using (var tran = Connection.BeginTransaction(IsolationLevel.ReadUncommitted))
- {
Advertisement
Add Comment
Please, Sign In to add comment