Explicit transactions?

2 posts, 0 answers
  1. Patrik
    Patrik avatar
    1 posts
    Member since:
    Aug 2010

    Posted 18 Sep 2013 Link to this post

    Hi

    When working with older versions of Openaccess I often do something like this in data methods:

    bool shouldCommit = !scope.Transaction.IsActive;
     
    if(shouldCommit)
        scope.Transaction.Begin();
     
    //Do some stuff
     
    if(shouldCommit)
        scope.Transaction.Commit();

    This way I could either call the method "on its own" or as part of a transaction, along with other such methods,
    in which case the transaction was handled in the calling method.

    Now with the newer versions, I can't find a way to explicitly start a transaction.
    You only call context.SaveChanges() to commit the transaction.

    Is there a way I can achieve the old behavior, short of passing along a parameter to indicate whether to commit or not?
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 19 Sep 2013 Link to this post

    Hi Patrik,

    I am afraid you cannot control the transactions using the Context API. If you want to achieve that goal you need to use the old classic API.

    I am sorry for the inconvenience caused.

    Regards,
    Damyan Bogoev
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
Back to Top