Note that there are some explanatory texts on larger screens.

plurals
  1. POTransaction on the Client Side
    primarykey
    data
    text
    <p>i have a big problem to use or understand the use of transaction with wsdualhttpbinding WCF.</p> <p>i have something like this :</p> <p><strong>IService :</strong></p> <pre><code>[ServiceContract] public interface IService { //... [OperationContract] [ApplyDataContractResolver] [TransactionFlow(TransactionFlowOption.Mandatory)] bool SaveDevice(Device device); //... } </code></pre> <p><strong>Service.svc.cs :</strong></p> <pre><code>[ServiceBehavior(IncludeExceptionDetailInFaults = true)] public class Service : IService { [OperationBehavior(TransactionScopeRequired = true)] public bool SaveDevice(Device device) { bool temp = false; Transaction transaction = Transaction.Current; using (EntityConn context = new EntityConn()) { try { //.... } } } } </code></pre> <p><strong>Model.cs</strong> So here im in my Client an try to execute an Operation with Transaction requirements :</p> <pre><code>if (Transaction.Current.TransactionInformation.DistributedIdentifier == Guid.Empty) { using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { try { //do some stuff } } } </code></pre> <p>Well im getting an Error : Transaction.Current is empty</p> <ol> <li>Do i on the right way?</li> <li>When not how can i solve it?</li> </ol> <p>Thank u for helping</p> <p><strong>EDIT</strong> : I just needed to place the if after the using</p> <pre><code> using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { if (Transaction.Current.TransactionInformation.DistributedIdentifier == Guid.Empty) { try { //do some stuff } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload