HierarchyId
Last updated
Last updated
HierarchyId
class provides tools for operating with identificators of objects combined into hierarchical structure. The idea of hierarchical id becomes helpful when working of objects combined into hierarchical structures. It could be organization departments for example.
Instance of HierarchyId
represents hierarchical identificator for node and contain ids of all ancestors for current node. For example it could be: "/10/38/94/", which means that current node has id=94
, its parent id is 38
and grandparent id is 10
.
Methods of this class allows getting ancestor of needed level, check if current node is descendant of some other node, move nodes in hierarchy etc.
All methods are described below:
Method name | Return type | Description |
---|---|---|
Constructor
HierarchyId
Initializes a new instance of the HierarchyId
class that holds data about provided nodes ids.
GetNode
int
Gets last node in current branch of hierarchy
IsDescendantOf
bool
Determines whether current node is descendant of specified node.
GetAncestor
HierarchyId
Gets ancestor of current node n-levels higher than itself.
GetDescendant
HierarchyId
Gets hierarchical id for direct descendant of current node with regular id specified.
GetLevel
int
Gets level in hierarchy for current node.
Move
-
Moves current node from its current ancestor to new one.
ToString
string
Creates string representation of current HierarchyId.
Parse
HierarchyId
Creates HierarchyId
instance from its string representation.