transactionscope

Difference Between Transaction and TransactionScope

我的梦境 提交于 2020-01-22 07:16:08
问题 I am developing an application which communicates with an SQL Server 2005 database to execute some stored procedures. My client demands that all transactions be managed on the C# side and not by SQL Server, and so I am using System.Transactions.TransactionScope when accessing the database. However, I have just seen the System.Transactions.Transaction datatype, and I am confused... What are the main pros/cons of each type? Which one should I use? Please note that I must also use Enterprise

Difference Between Transaction and TransactionScope

有些话、适合烂在心里 提交于 2020-01-22 07:15:26
问题 I am developing an application which communicates with an SQL Server 2005 database to execute some stored procedures. My client demands that all transactions be managed on the C# side and not by SQL Server, and so I am using System.Transactions.TransactionScope when accessing the database. However, I have just seen the System.Transactions.Transaction datatype, and I am confused... What are the main pros/cons of each type? Which one should I use? Please note that I must also use Enterprise

Dapper & TransactionScope?

…衆ロ難τιáo~ 提交于 2020-01-20 13:21:46
问题 I just started playing around with Dapper. So far i love it. Does dapper not work with TransactionScope ? I noticed that even if i never call TransactionScope.Complete then my changes are still committed to the database. If TransactionScope isn't supported now is there any plans in the future to support it? If not then you have to use traditional transaction management (System.Transactions.Transaction)? Update: I just talked to Sam over Twitter. It should work. I'll update it tomorrow morning

Dapper & TransactionScope?

不问归期 提交于 2020-01-20 13:21:36
问题 I just started playing around with Dapper. So far i love it. Does dapper not work with TransactionScope ? I noticed that even if i never call TransactionScope.Complete then my changes are still committed to the database. If TransactionScope isn't supported now is there any plans in the future to support it? If not then you have to use traditional transaction management (System.Transactions.Transaction)? Update: I just talked to Sam over Twitter. It should work. I'll update it tomorrow morning

Intermittent System.ArgumentNullException using TransactionScope

女生的网名这么多〃 提交于 2020-01-14 14:17:07
问题 I have a Windows Service application which is performing some calls to SQL Server. I have a particular unit of work to do which involves saving one row to the Message table and updating multiple rows in the Buffer table. I have wrapped these two SQL statements into a TransactionScope to ensure that they either both get committed, or neither get committed. The high level code looks like this: public static void Save(Message message) { using (var transactionScope = new TransactionScope()) {

C# Azure Storage Blob Upload TransactionScope

不问归期 提交于 2020-01-14 09:35:47
问题 Is there somewhere a class to allow roll back with transactionscope on azure blockblob actions ? I would like make this works: CloudBlockBlob blockBlob; private void UploadPicture(Stream iStream) { using(var ts = new TransactionScope()) { blockBlob.UploadFromStream(iStream); throw new Exception(); ts.Complete(); } } When the exception is raise, the uploaded file is not cancelled. If is not possible with transaction scope, how should I proceed ? 回答1: Azure Storage Client Library does not

Hierarchy of TransactionScope

旧城冷巷雨未停 提交于 2020-01-13 16:44:12
问题 Is it possible to have a hierarchy of transaction scopes? If the outer transaction scope does a dispose, what will happen to changes made in the inner transaction scope? My particular problem is that I have test code that runs code that has a transaction scope. When I call a second set of code with a transaction scope I get "Cannot access a disposed object. Transaction". Could it be that the dispose of the inner transaction scope is also disposing the outer transaction scope. 回答1: I doubt

Is it important to Open a sql connection in the transactionscope

人走茶凉 提交于 2020-01-13 08:57:09
问题 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? ... } 回答1: It

Is it possible to create a TransactionScope in a Custom WCF Service Behavior? (async, await, TransactionScopeAsyncFlowOption.Enabled)

北城以北 提交于 2020-01-12 07:25:48
问题 TL;DR ? Screencast explaining problem: https://youtu.be/B-Q3T5KpiYk Problem When flowing a transaction from a client to a service Transaction.Current becomes null after awaiting a service to service call. Unless of course you create a new TransactionScope in your service method as follows: [OperationBehavior(TransactionScopeRequired = true)] public async Task CallAsync() { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await _service.WriteAsync(); await

How to support async methods in a TransactionScope with Microsoft.Bcl.Async in .NET 4.0?

允我心安 提交于 2020-01-12 04:12:32
问题 I have a method similar to: public async Task SaveItemsAsync(IEnumerable<MyItem> items) { using (var ts = new TransactionScope()) { foreach (var item in items) { await _repository.SaveItemAsync(item); } await _repository.DoSomethingElse(); ts.Complete(); } } This of course has issues because TransactionScope doesn't play nice with async/await. It fails with an InvalidOperationException with the message: "A TransactionScope must be disposed on the same thread that it was created." I read about