The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

esTransactionScope supporting non-EntitySpaces activty as well?

Last post 02-17-2007, 7:52 AM by Mike.Griffin. 3 replies.
Sort Posts: Previous Next
  •  02-15-2007, 6:06 PM 331

    esTransactionScope supporting non-EntitySpaces activty as well?

    Will esTransactionScope utilize DTC for distributed transactions, even if a mix of EntitySpaces and non-EntitySpaces DB/web service/etc activity takes place within the esTransactionScope block?  (i.e. other custom class/objects that conduct activity that are not inherited from any of the EntitySpaces classes)

     
    Thanks! 

     

     

     

  •  02-16-2007, 6:55 AM 337 in reply to 331

    Re: esTransactionScope supporting non-EntitySpaces activty as well?

    The esTransactionScope is getting a major overhaul, I'm working on it now, it's awesome, you can do this now:

     

    Code:
    using(esTransactionScope scope1 = new esTransactionScope())
    {
      // esTransactionScopeOption.Required is the default 
      using(esTransactionScope scope2 = new esTransactionScope(esTransactionScopeOption.RequiresNew)
      {
        // scope2 begins a new root transaction and will complete seperate from scope1
        using(esTransactionScope scope3 = new esTransactionScope()
        {
          // scope3 joins scope2, it's root parent
          scope3.Complete();
        }
    
        scope2.complete();
      }
    
      using(esTransactionScope scope4 = new esTransactionScope(esTransactionScopeOption.Suppress)
      {
        // esTransactionScopeOption.Suppress means use no transaction, even if nested like this
        // So anything done in here runs without a transaction
    
        scope4.Complete();
      }
    
      scope1.Complete();
    }

    I will be doing a blog post on some of the features rolling into es 1.6.0

    As for distributed transaction, we do support them, here's how.

    Just change your connection string "providerClass" from DataProvider to DataProviderEnterprise and EntitySpaces will use the Microsoft  TransactionScope internally and you can as well.

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  02-16-2007, 10:46 PM 361 in reply to 337

    Re: esTransactionScope supporting non-EntitySpaces activty as well?

    Thank for that.  To clarify another point (and I have not had the chance to test EntitySpaces yet):

     Can you do this, and expect TransactionScope and esTransactionScope to work properly, use DTC and expect no surprises:

     

     

    Code:
    using(TransactionScope scope1 = new TransactionScope())
    {
      // use sqlcommand to insert into some db, totally not entityspaces related
      // executenonquery()
    
      using(esTransactionScope scope2 = new esTransactionScope()
      {
       // use EntitySpaces objects and DB functionality.
       // entity.save();
    
        scope2.complete();
      }
      scope1.Complete();
    }

    And this will work if the nesting is opposite? (esTransactionScope, then TransactionScope)?
     
  •  02-17-2007, 7:52 AM 364 in reply to 361

    Re: esTransactionScope supporting non-EntitySpaces activty as well?

    Yes, because all we are doing is using ADO.NET connections and transactions which should be automatically enlisted by the DTC. Did you see our new blog post today? off the main site, you should subscribe if you haven't already, I am writing the unit tests for the Transactions today and will test what you've shown above, but I encourage you too as well.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML