Try our conversational search powered by Generative AI!

Are Transactions available when working with Business Foundation objects?

Vote:
 

Is it possible to wrap Business Manager Create/Update/Delete Calls in Transaction?

e.g.

If I were to use Business Manager to Create 5 entries in my custom class. I would like to initially open a Transaction, then should an error occur Creating any of objects, do a rollback.  If all Creates were a success then explicitly call a Commit.

Can this be done with Business Manager?

 

#75983
Oct 15, 2013 0:03
Vote:
 

This should be possible.  The Create/Update/Delete calls all have their own transaction via the Execute() method.  I'm not sure what check you are doing to see if all the Creates were successful but you should be able to wrap it in a transaction.

// Run transaction
using (TransactionScope tran = DataContext.Current.BeginTransaction())
{

PrimaryKeyId keyId = BusinessManager.Create(entityobject);

// if the entity was created then Commit the transaction for all of the objects, since this should be the root transaction ALL the objects should be created/updated/deleted

tran.Commit();
}

#76035
Oct 15, 2013 23:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.