1
Vote

Calling TransactionManager.RequireNew in a loop prevents infoset part persisting changes

description

Hello,


Running the following code:
foreach(var part in parts)
{
    var autoroutePart = part.As<AutoroutePart>();
    autoroutePart.DisplayAlias = part.NewUrl;

    _orchardServices.TransactionManager.RequireNew();
}
After the first iteration, the Orchard_Autoroute_AutoroutePartRecord.DisplayAlias field is updated in the database, however, the Orchard_Framework_ContentItemVersionRecord.Data field is not.


Running the code with RequireNew at the end of the loop, does however commit the database changes:
foreach(var part in parts)
{
    var autoroutePart = part.As<AutoroutePart>();
    autoroutePart.DisplayAlias = part.NewUrl;
}

_orchardServices.TransactionManager.RequireNew();

comments