Im sure this is so basic question but i can't found any solution on google neither here.
when im trying to use that code block it throws an exception that 'System.Activities.Statements.TransactionScope': type used in a using statement must be implicitly convertible to 'System.IDisposable'
using (TransactionScope trans = new TransactionScope())
{
}
Simply, i want to use TransactionScope in Linq code.
Thanks, Regards
You are likely using the wrong TransactionScope.
The one you're looking for is System.Transactions.TransactionScope
, which resides in the System.Transactions.dll assembly. Make sure it's referenced (it's not by default), and that you are "using System.Transactions
".
I don't know what System.Activities.Statements.TransactionScope
is but you want System.Transactions.TransactionScope
. You'll also need a reference to System.Transactions.dll
.
From the documentation:
public sealed class TransactionScope : IDisposable
Note that System.Activities.Statements.TransactionScope
lives in System.Activities.Statements
which is described as
The
System.Activities.Statements
namespace contains activities that can be used to create workflows. This namespace contains activities that are used for flow control, interacting with collections and variables, exceptions, compensation, transactions, and interacting with legacy workflows.
which is clearly not appropriate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With