transactionscope

C# System.Transactions Vs TransactionScope

﹥>﹥吖頭↗ 提交于 2021-02-05 09:24:26
问题 Based on this article here as well as the question: Difference Between Transaction and TransactionScope we know that TransactionScope The TransactionScope class provides a simple way to mark a block of code as participating in a transaction, without requiring you to interact with the transaction itself. A transaction scope can select and manage the ambient transaction automatically. Due to its ease of use and efficiency, it is recommended that you use the TransactionScope class when

Do I need to close the DbConnection manually when using ambient transactions with EF Core 2.1?

我是研究僧i 提交于 2021-01-27 13:38:51
问题 EF Core 2.1 introduced support for ambient transactions. The sample creates a new SqlConnection , manually opens it and passes it to the DbContext : using (var scope = new TransactionScope( TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) { var connection = new SqlConnection(connectionString); connection.Open(); try { // Run raw ADO.NET command in the transaction var command = connection.CreateCommand(); command.CommandText = "DELETE

Using TransactionScope with Stored Procedure Transaction does not work

耗尽温柔 提交于 2020-12-13 03:32:35
问题 As per my understanding, C# TransactionScope can still work when wrapping a T-SQL BEGIN / COMMIT TRANSACTION inside a stored procedure. I have the following C# method which does EF Save first, then call a stored procedure that has its own transaction and then call external service over HTTP public async Task DoSomething(MyDto dto) { using (var scope = new TransactionScope()) { //Save First var myEntity = await _dbContext.MyEntity.Where(x=>x.Id == dto.Id).SingleOtDefaultAsync(); // Assign

Using TransactionScope with Stored Procedure Transaction does not work

橙三吉。 提交于 2020-12-13 03:30:39
问题 As per my understanding, C# TransactionScope can still work when wrapping a T-SQL BEGIN / COMMIT TRANSACTION inside a stored procedure. I have the following C# method which does EF Save first, then call a stored procedure that has its own transaction and then call external service over HTTP public async Task DoSomething(MyDto dto) { using (var scope = new TransactionScope()) { //Save First var myEntity = await _dbContext.MyEntity.Where(x=>x.Id == dto.Id).SingleOtDefaultAsync(); // Assign

Inner TransactionScope with different IsolationLevel, how can it be achieved?

柔情痞子 提交于 2020-06-27 15:54:09
问题 The current implementation of TransactionScope lacks the ability to change IsolationLevels in nested scopes. MSDN states: When using nested TransactionScope objects, all nested scopes must be configured to use exactly the same isolation level if they want to join the ambient transaction. If a nested TransactionScope object tries to join the ambient transaction yet it specifies a different isolation level, an ArgumentException is thrown. However SQL Server allows us to change Isolation Levels

Transaction can't handle parallel commands via Task.WhenAll

眉间皱痕 提交于 2020-02-24 10:19:53
问题 I have some main table (like Companies) and a lot of dependent tables (like CompanyAddresses, CompanyPaymentInfos, etc.) in my Postgres DB: CREATE TABLE Companies ( Id uuid NOT NULL PRIMARY KEY, ...); CREATE TABLE CompanyAddresses( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); CREATE TABLE CompanyPaymentInfos( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); I use transactions from standard library in my C# code: private TransactionScope

Transaction can't handle parallel commands via Task.WhenAll

混江龙づ霸主 提交于 2020-02-24 10:19:38
问题 I have some main table (like Companies) and a lot of dependent tables (like CompanyAddresses, CompanyPaymentInfos, etc.) in my Postgres DB: CREATE TABLE Companies ( Id uuid NOT NULL PRIMARY KEY, ...); CREATE TABLE CompanyAddresses( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); CREATE TABLE CompanyPaymentInfos( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); I use transactions from standard library in my C# code: private TransactionScope

Enable Async TransactionScope without TransactionScopeAsyncFlowOption.Enabled

╄→гoц情女王★ 提交于 2020-02-04 04:39:14
问题 Following is Async Cache and Database update using Transaction Scope. I cannot use TransactionScopeAsyncFlowOption.Enabled introduced in the v 4.5.1, since the Apache Ignite.Net Cache I am using doesn't support it. I have tried finding a workaround by capturing the current Synchronization Context and then explicitly using Synchronization Context Send method to complete the transaction, but this doesn't work as I still get an error Transaction scope must be disposed on same thread it was