internal void RemoveNode(TaxonomyNode taxonomyNode, bool includeChildren) { if (taxonomyNode.IsDetached) { throw new Exception(String.Format("Taxon '{0}' is detached", taxonomyNode.Name)); } if (taxonomyNode == rootNode) { throw new Exception("Can't remove root"); } if (!includeChildren && taxonomyNode.Children.Count > 0) { throw new DataLayerException("Taxon have children"); } var nodesToRemove = new List <TaxonomyNode>(taxonomyNode.GetAllChildren()); nodesToRemove.Add(taxonomyNode); foreach (var node in nodesToRemove) { node.IsDetached = true; repo.Delete(node.entity); } taxonomyNode.Parent.children.Remove(taxonomyNode); }