This is a migrated thread and some comments may be shown as answers.

Explicit transactions?

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrik
Top achievements
Rank 1
Patrik asked on 18 Sep 2013, 04:12 PM
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?

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 19 Sep 2013, 12:58 PM
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.
Tags
General Discussions
Asked by
Patrik
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or