Updates ClearPublished logic to be done in a single SQL statement instead of several

This commit is contained in:
Shannon
2017-02-15 21:22:08 +11:00
parent e619c402b4
commit 0c613347ae

View File

@@ -785,13 +785,8 @@ order by umbracoNode.{2}, umbracoNode.parentID, umbracoNode.sortOrder",
public void ClearPublished(IContent content)
{
// race cond!
var documentDtos = Database.Fetch<DocumentDto>("WHERE nodeId=@id AND published=@published", new { id = content.Id, published = true });
foreach (var documentDto in documentDtos)
{
documentDto.Published = false;
Database.Update(documentDto);
}
var sql = "UPDATE cmsDocument SET published=0 WHERE nodeId=@id AND published=1";
Database.Update(sql, new {id = content.Id});
}
/// <summary>