transactionscope

Entity Framework and Transactionscope doesn't revert the isolation level after dispose of Transactionscope

我们两清 提交于 2019-12-09 09:20:37
问题 I am struggeling a bit with transaction scopes and entity framework. Initially we want all our connections in the application to use snapshot isolation level when reading data, but in some circumstances we want to read data with either read committed or read uncommitted isolation level and for this we will use transaction scopes to change the isolation level temporary for queries (as pointed out in several posts here and in different blogs). However, the problem is that when the transaction

TransactionScope - The underlying provider failed on EnlistTransaction. MSDTC being aborted

China☆狼群 提交于 2019-12-09 08:15:46
问题 Our team have got a problem that manifests as: The underlying provider failed on EnlistTransaction; Cannot access a disposed object.Object name: 'Transaction'. which seemed to appear as soon as we began using TransactionScope to handle our applications' transactions. The top part of the stacktrace is captured as: at System.Data.EntityClient.EntityConnection.EnlistTransaction(Transaction transaction) at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectContext

using transaction with task parallel library

自作多情 提交于 2019-12-08 06:47:57
问题 I have N process to run over SQL Server 2008. If any of the processes fails I need to rollback all the others. I was thinking to use the TPL creating a parent task and N child task. All of this enclosed with a transactionScope (IsolationLevel.ReadCommitted) but in my example below, the child2 throws an error(customers2 is not a valid table) and the child1 doesn't rolled back. Am I assuming something wrong here? is there other way to manage this scenario? Here is my test code: edit I modified

nhibernate and transactionscope transaction aborted spontaniously

北慕城南 提交于 2019-12-08 06:37:32
I am working with Nhibernate and TransactionScope in a large application. The application is supposed to modify 3 databases and support a distribuited transaction across them. This is the code that I call each time I want to query or execute some sql on the database within the distribuited transaction: IDbConnection connection = new SqlConnection(connectionString); connection.Open(); ISession session = SessionFactory.OpenSession(connection); And this is the code called whenever after the necessary operations are executed IDbConnection sqlConnection = session.Connection; if (sqlConnection !=

How To Implement transaction in Business logic layer

◇◆丶佛笑我妖孽 提交于 2019-12-07 11:17:37
问题 I'am using enterprise library data access block in my asp.net application. I want to implement transaction from the Business logic layer, across multiple stored procs. Entlib opens a new connection for database access. Does using Transaction Scope in the following way lead to distributed transaction? using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { // calling necessary DAL methods scope.Complete(); } Is there better methods to implement transaction from

EF Core 2.0 TransactionScope Error

流过昼夜 提交于 2019-12-07 10:31:32
问题 I am trying to use TransactionScope in my SELECT query in EntityFramework Core 2.0. However I am getting this error : "Enlisting in Ambient transactions is not supported." The idea is to implement "NO LOCK" option (I know it's not a good idea to have that option in place but it's vendor's requirement) when I do select query. So I added an extension method (Entity Framework with NOLOCK) public static async Task<List<T>> ToListReadUncommittedAsync<T>(this IQueryable<T> query) { using (var scope

using transaction with task parallel library

六月ゝ 毕业季﹏ 提交于 2019-12-07 07:33:24
I have N process to run over SQL Server 2008. If any of the processes fails I need to rollback all the others. I was thinking to use the TPL creating a parent task and N child task. All of this enclosed with a transactionScope (IsolationLevel.ReadCommitted) but in my example below, the child2 throws an error(customers2 is not a valid table) and the child1 doesn't rolled back. Am I assuming something wrong here? is there other way to manage this scenario? Here is my test code: edit I modified the code as below using the DependClone on the current transaction. I think is working. try { using

CRM 2011 SDK transaction

泪湿孤枕 提交于 2019-12-07 06:28:50
问题 How to create transaction using crm 2011 sdk and XrmServiceContext? In next example 'new_brand' is some custom entity. I want to create three brands. Third has wrong OwnerID guid. When I call SaveChanges() method, two brands are created and I've got exception. How to rollback creating of first two brands? Is it possible without using pluggins and workflows? using (var context = new XrmServiceContext(connection)) { SystemUser owner = context.SystemUserSet.FirstOrDefault(s => s.Id == new Guid(

TransactionScope across AppDomains and processes

北战南征 提交于 2019-12-07 06:05:49
问题 Is it real to use System.Transactions (primarily TransactionScope) across different AppDomains and processes? DependentTransaction works only inside one AppDomain. 回答1: Yes, it works. We are flowing transactions via WCF, calling out of process transactional COM+ components, and manually passing transactions from a .NET 2.0 asmx web service to a WCF service. Now that is not to say that the setup is not finicky. I think most of the issues were around getting MSDTC set up properly on all the

Nhibernate with TransactionScope Error - DTC transaction prepre phase failed — Upgrade to Nhibernate 3.0

淺唱寂寞╮ 提交于 2019-12-07 05:04:07
问题 I am getting the following exception when using Nhibernate and ADO.Net operations inside the transaction Scope.Eg. It was fine with Nhibernate 2.1 but now upgraded to 3.0 which throws error. using (var scope = new TransactionScope(TransactionScopeOption.Required)) { GetmemberId(); --> NHibernate Call Update(); ADO Call OracleDB } Since this acts as ambient transaction, Nhibernate tries to dispose the transaction soon before the outer transaction completes.correct me if I am wrong, Is there