Skip to content

Commit

Permalink
Fix bulk property variant data updates (#12569)
Browse files Browse the repository at this point in the history
(cherry picked from commit a242a42)
  • Loading branch information
ronaldbarendse authored and bergmania committed Jan 30, 2024
1 parent 104ba5f commit fee470c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1128,18 +1128,24 @@ private void RenormalizeDocumentEditedFlags(IReadOnlyCollection<int> propertyTyp
}
}

//Now bulk update the table DocumentCultureVariationDto, once for edited = true, another for edited = false
// Now bulk update the table DocumentCultureVariationDto, once for edited = true, another for edited = false
foreach (var editValue in toUpdate.GroupBy(x => x.Edited))
{
Database.Execute(Sql().Update<DocumentCultureVariationDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentCultureVariationDto>(x => x.Id, editValue.Select(x => x.Id)));
foreach (var ids in editValue.Select(x => x.Id).InGroupsOf(Constants.Sql.MaxParameterCount))
{
Database.Execute(Sql().Update<DocumentCultureVariationDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentCultureVariationDto>(x => x.Id, ids));
}
}

//Now bulk update the umbracoDocument table
// Now bulk update the umbracoDocument table
foreach (var editValue in editedDocument.GroupBy(x => x.Value))
{
Database.Execute(Sql().Update<DocumentDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentDto>(x => x.NodeId, editValue.Select(x => x.Key)));
foreach (var ids in editValue.Select(x => x.Key).InGroupsOf(Constants.Sql.MaxParameterCount))
{
Database.Execute(Sql().Update<DocumentDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentDto>(x => x.NodeId, ids));
}
}
}

Expand Down

0 comments on commit fee470c

Please sign in to comment.