Skip to content

Instantly share code, notes, and snippets.

@VisualBean
Last active November 30, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VisualBean/62ab4d94f9b7efdf332d to your computer and use it in GitHub Desktop.
Save VisualBean/62ab4d94f9b7efdf332d to your computer and use it in GitHub Desktop.
Creating a tree from a flat list of "Organizations"
parents.foreach(p => p.childs = parents.Where(pa => pa.ParentId == p.Id));
return parents.Where(p => p.Id == null); //Returns the very top of the tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment