Query for updating a node in hierarchial tree structure
I like to make my Ancestor and Offspring gerund types actual entity types because it helps me get the Separation between the Ancestor and Offspring (what you referred to as Depth). We want to be able to express this filter as an CREATE FUNCTION [dbo].[Descendants Of] ( @parent Id int ) RETURNS TABLE AS RETURN ( WITH descendants (Node ID, Parent Node ID, Leaf ID) AS( SELECT Node ID, Parent Node ID, Leaf ID from Nodes where Parent Node ID = @parent Id UNION ALL SELECT n.
The last two columns are auto-computed to help with searching so we can ignore them for now.I'm creating a drop down menu system with multiple categories. This query helps you to get a root node and load all children.Unfortunately EF I don't think plays nice with Self referencing tables more than 1 level deep. Without playing with introducing Ancestors and Descendants. A typical example is a table in a relational database where each record’s “parent” field references the primary key of another record.
Of course, Tree cannot only use data originating from a database, but anything: you supply the data, and Tree uses it, regardless of where the data came from and how it was processed.What I finally settled on was the addition of a new gerund entity, along with 2 new entity properties: While writing this up, hazzik posted an answer that is very similar to this approach. As the user opens nodes in the file system tree, we only want to show that user nodes that will, eventually, lead them to the files they can see.