Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created September 9, 2013 18:13
Show Gist options
  • Save csharpforevermore/6499384 to your computer and use it in GitHub Desktop.
Save csharpforevermore/6499384 to your computer and use it in GitHub Desktop.
In Umbraco Razor, sometimes it is necessary to get a random few nodes. This example allows you to get a random collection of child nodes.
// take specific amount from randomised collection of the children
var children = CurrentModel.Children;
var random = new Random();
var shuffled = children.OrderBy(i => random.Next()).ToList().Take(childCount);
children = new DynamicNodeList(shuffled);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment