transactionscope

How To Implement transaction in Business logic layer

血红的双手。 提交于 2019-12-05 17:50: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 BLL? If you're talking about SQL Server as the backend, it depends on the server version. Here is a

DTC firewall requirements?

倖福魔咒の 提交于 2019-12-05 13:22:11
I'm attempting to set up an environment in which a TransactionScope originating on a web server (asp.net) will flow a transaction through WCF to an application server and subsequently through to the database. Since I'm forced to use a SQL Server 2005 database, this often causes the transaction to be 'promoted' to a distributed transaction (several service calls could be wrapped in this TransactionScope), which means the Distributed Transaction Coordinator needs to be enabled. I've successfully got it working on a local box where the web server and app server are hosted on the same machine,

TransactionScope across AppDomains and processes

半世苍凉 提交于 2019-12-05 11:22:04
Is it real to use System.Transactions (primarily TransactionScope) across different AppDomains and processes? DependentTransaction works only inside one AppDomain. 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 servers. UPDATE We don't use DependentClone . We are passing the transaction as a byte array using

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

笑着哭i 提交于 2019-12-05 10:11:52
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 any solution because help me , But When I move the Nhibernate call outside TransactionScope everything

CRM 2011 SDK transaction

泄露秘密 提交于 2019-12-05 09:56:45
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("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")); // create 3 brands new_brand b1 = new new_brand(); b1.new

Where should I perform action when implementing IEnlistmentNotification?

泄露秘密 提交于 2019-12-05 08:27:35
I am trying to create a custom "resource manager" by implementing IEnlistmentNotification interface. This interface has following methods: Prepare() Commit() Rollback() InDoubt() While it's clear that rollback code should go in Rollback() method I am not sure in which method should I implement the code that performs the actual operation? Should it go in Prepare() or Commit() or maybe some other custom method in the class that will be called from outer code from inside of TransactionScope block? The actual work should be performed in another method. Prepare and Commit are there to implement a 2

TransactionScope Timeout occurs prematurely?

ε祈祈猫儿з 提交于 2019-12-05 05:36:34
I'm using TransactionScope to do some batch insert and updates. Problem is, I'm getting timeout exceptions on a 30 min long operation even when I set the timeout of the TransactionScope to one hour. Also after the exception it inserts seemingly random amount of the records of the batch. For example the last operation had 12440 inserts and after the timeout there were 7673 records inserted to the table. The timeout of the SqlConnection and SqlCommand are both set to int.MaxValue . What am I doing wrong? Here's my code: using (TransactionScope transaction = new TransactionScope

Is it important to Open a sql connection in the transactionscope

笑着哭i 提交于 2019-12-05 05:16:55
I created a sqlconnection, CN1. Then this CN1 is opened. Later in the code there is a transactionscope. If I execute a sql command on this CN1 connection, is this within transaction? Code looks like this; SqlConnection cn1 = new SqlConnection(); cn1.Open(); //connection opened when there is no ambient transaction. ... using(TransactionScope scope = new TransactionScope()) { SqlCommand cmd; //a typical sql command. ... cmd.ExecuteNonQuery(); //Is this command within transaction? ... } It is a MUST to open the connection within the TransactionScope to ensure that the connection is enrolled in

Preparing for multiple EF contexts on a unit of work - TransactionScope

╄→尐↘猪︶ㄣ 提交于 2019-12-05 02:24:39
问题 I'm thinking of the options in regards to implementing a single unit of work for dealing with multiple datasources - Entity framework. I came up with a tentative approach - for now dealing with a single context - but it apparently isn't a good idea. If we were to analyze the code below, would you consider it a bad implementation? Is the lifetime of the transaction scope a potential problem? Of course if we wrap the transaction scope with different contexts we'd be covered if the second

TransactionScope Complete() doesn't commit the transaction before exiting the USING statement

穿精又带淫゛_ 提交于 2019-12-05 01:55:47
I am experiencing this weird behavior where the transaction gets committed only when the using exits and not when calling scope.Complete(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { scope.Complete(); // data still doesn't show in db } // now shows in db How do I commit the transaction before exiting the using statement? NDJ from the documentation : The actual work of commit between the resources manager happens at the End Using statement if the TransactionScope object created the transaction. So it doesn't look like you can truly commit the