3

I would like to move a content node and change some properties. But it should be done in a transaction. The operations are done with PetaPoco Framework and it support transactions. Looking for the proper way to achieve transactional content updates.

I just wrote the following imaginary code to demonstrate what I'd like to achieve. I need something like this:

using (var transaction = DatabaseContext.Database.GetTransaction())
{
    var content = Services.ContentService.GetById(model.Id);
    Services.ContentService.Move(content, parentId);
    content.SetValue("prop", "value");
    Services.ContentService.SaveAndPublishWithStatus(content);
    transaction.Complete();
}
Marton Rusko
  • 370
  • 2
  • 8
  • 1
    FYI: the code example looks surprisingly close to the syntax we're actually using for scopes so your imaginary code should only require minimal changes when scopes are available. – Claus Feb 21 '17 at 21:35

1 Answers1

3

There's unfortunately no way to do this right now, as the services do not support transactions/scopes.

It will however be possible to do this in the future, as we're currently implementing transactions (scopes) for internal use in the service layer in v. 7.6. I am not sure when it will be possible to use this outside of the Core namespace as we still have some testing to do, but it will hopefully be soon.

Claus
  • 1,975
  • 18
  • 24