none
Multiblle DataContext in the Same Transaction RRS feed

  • Question

  • Hi All
    i Have a Case where I need to call multible Methods each will call defferent DataContext and I need to ensure that all these method will run under the Same transaction dose any one have an idea how to do this  or if LINQ have built i Support
    Thanks
    Wednesday, June 3, 2009 4:49 PM

All replies

  • Wrap them in a TransactionScope:

    http://msdn.microsoft.com/en-us/library/ms172152.aspx

    Regards

    Joe
    Write LINQ queries interactively - www.linqpad.net
    Thursday, June 4, 2009 4:40 AM
    Answerer
  • thanks alot :-)
    Thursday, June 4, 2009 7:50 AM
  • I used the transaction Scope
    but I have the following Error

     

     

    {

     

    trans.Complete();

    }



    Error HRESULT E_FAIL has been returned from a call to a COM component.   at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)
       at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken)


    I am running Windows server 2008 do I have to do any changes to DTC on my machine ?


    base.Run();
    using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, transOpt))
    TransactionOptions transOpt = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted };
    Thursday, June 4, 2009 8:00 AM
  • The following might help:

    http://social.msdn.microsoft.com/Forums/en-US/windowstransactionsprogramming/thread/24b682d1-e790-4f30-9a2d-6bbf272116c8

    Regards

    Joe
    Write LINQ queries interactively - www.linqpad.net
    Friday, June 5, 2009 2:29 AM
    Answerer