transactionscope

TransactionScope and Npgsql - Prepared Transaction Issue

扶醉桌前 提交于 2019-12-11 01:38:42
问题 I have following code: //... using (TransactionScope tScope = new TransactionScope()) { using (NpgsqlConnection myConnection = new NpgsqlConnection(_MyConnectionString)) { try { myConnection.Open(); //... tScope.Complete(); } catch (Exception ex) { logger.Error(ex); } finally { myConnection.Close(); } } } //... The problem is, when some error occurred transactionscope do rollback, but, on the PostgreSQL server I have prepared transaction. And applications can not work anything with database

T-SQL Equivalent of .NET TransactionScopeOption.Suppress

家住魔仙堡 提交于 2019-12-11 01:27:38
问题 In my .NET code, inside a database transaction (using TransactionScope), I could include a nested block with TransactionScopeOption.Suppress , which ensures that the commands inside the nested block are committed even if the outer block rolls back. Following is a code sample: using (TransactionScope txnScope = new TransactionScope(TransactionScopeOption.Required)) { db.ExecuteNonQuery(CommandType.Text, "Insert Into Business(Value) Values('Some Value')"); using (TransactionScope txnLogging =

TransactionScope nuances

*爱你&永不变心* 提交于 2019-12-10 20:15:59
问题 Let's imagine I have two threads which execute some database-oriented code in thread-specific TransactionScopes with ReadCommitted isolation level. But there is some table which data should be shared (no duplicates should be created). using (var transactionScope = new TransactionScope(IsolationLevel.ReadCommitted)) { ...//some code if (!_someRepository.IsValueExists(value)) _someRepository.AddData(value); ...//some code transactionScope.Complete(); } The problem is both threads may check

The transaction must be disposed before the connection can be used to execute sql statements

你说的曾经没有我的故事 提交于 2019-12-10 17:00:04
问题 I am getting this error The transaction must be disposed before the connection can be used to execute sql statements. i have an Excel file that contains about 6000 rows and I uploaded these file into Data table in typed dataset, then I am trying to apply my business logic on these rows in dt. The exception throws from the second loop and I have to do two loops; why does this exception occur, and how can I solve it? Here is my code: try { using (TransactionScope scope = SysInfo

Doing transactions with Entity Framework Code First

左心房为你撑大大i 提交于 2019-12-10 16:45:34
问题 There is an answer here to explain how to do transactions with Entity Framework However the solution does not work with code first. I have experimented and my tests indicate the following does work using (var scope = new TransactionScope()) { DBContext1.SaveChanges() If (ForceFailure) return 0 // used in testing DBContext2.SaveChanges() scope.Complete(); } However I feel nervous because I am no longer passing parameters to SaveChanges or calling AcceptAllChanges How do I establish whether I

Why am I getting this error suddenly?

大城市里の小女人 提交于 2019-12-10 12:37:17
问题 So I have a WCF service, inside which there's a Process() method. This method reads a byte array (a file) from one table, and basically puts that data from that file into multiple tables. It just iterates through each row. It was working fine since a month in the Production environment. Now all of a sudden, it throws this error intermittently: System.InvalidOperationException: The transaction associated with the current connection has completed but has not been disposed. The transaction must

RavenDB does not play nicely with Transaction Scope

懵懂的女人 提交于 2019-12-10 10:59:19
问题 I have the following test case that i expect to pass. But it does not pass with RavenDB. If i create the exact same test with MsSql, it does pass. var connectionString = "Url=http://localhost:8080"; var store = new DocumentStore(); store.ParseConnectionString(connectionString); store.Initialize(); using (var scope = new TransactionScope()) using (var session = store.OpenSession()) { session.Store(dog); session.SaveChanges(); var dogs = session.Query<Dog>().Customize(x => x

SqlConnection and avoiding promotion to MSDTC

谁说我不能喝 提交于 2019-12-10 01:56:52
问题 When we need to do database access in our application, we use the following patterns: For querying, we have a static factory class with a method CreateOpenConnection which does nothing more than new SqlConnection(myConnectionString) and calls Open() on it. This method gets called before we do a query and the connection is disposed after the query returns. For inserts/updates/deletes we use a Unit of Work pattern where the changes are batched up and submitted to the database with a call to

What is TransactionScope default Timeout value?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 01:24:53
问题 When i create a TransactionScope object as followed: using (TransactionScope ts = new TransactionScope()) { // Do stuff... } What is the default transaction timeout of the given ts object? 回答1: According to David Browne it is 1 minute TransactionScope’s default constructor defaults the isolation level to Serializable and the timeout to 1 minute using new TransactionScope() Considered Harmful 来源: https://stackoverflow.com/questions/20224748/what-is-transactionscope-default-timeout-value

SharePoint 2007: How can I perform a series of operations within a transaction?

冷暖自知 提交于 2019-12-09 18:08:21
问题 I would love to know how to perform a series of operations in a SharePoint context within a transaction. For example, I would like to be able to do something like the following: context.BeginTransaction(); listItemA.Update(); listItemB.Update(); context.CommitTransaction(); I know this isn't possible with the OOTB APIs, but someone has got to have figured out how to accomplish this. Is it possible to get a reference to the database connection in order to handle the transaction? Or any other