Anyone know of a simple way to ensure that updated child collections are retrieved after Nodes have been moved?
The issue I have is on moving a Node right only, when the
site.RootNodes. ChildNodes collection seems cached. Anyone help?
After a rebuild or waiting a while, all works fine again. The database has the correct data immediately after performing the update via the web service.
Solved by using
this.CoreRepository.ClearCollectionCache("Cuyahoga.Core.Domain.Node.ChildNodes");
after the 'move left' and
foreach (Node node in nodes.OrderBy(x => x.Position)){
build the site tree here...
}
When moving 'left' the node is removed from one collection and added to another. This places it out of order. The collections cache needs to be cleared after move so the collection is reloaded after postback otherwise the out of order collection will be used.
The copy method in the Node class seems to cause errors when more than one copy of a node is made.
The addition of this fixes:
newNode.Title = "Copy of " + this.Title;
//Custom: Check for existing copies and rename accordingly
if (parentNode.ChildNodes.Count > 0)
{
foreach (Node n in parentNode.ChildNodes)
{
if (newNode.Title == n.Title)
{
newNode.Title = "Copy of " + n.Title;
}
}
}
I also added methods for CanMoveUp, CanMoveDown, CanMoveLeft, CanMoveRight that return bool. These were required for AdminWebService.
Not that it helps that much in this case, but in 2.0 all logic for moving nodes has been rewritten. And yes, caching can be nasty in this scenario. I've been tempted to clear the entire second level cache after any update, but couldn't find a quick way to do it.