You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github-actions[bot] edited this page Dec 6, 2026
·
3 revisions
Use PreparedTrigger_MaintainHierarchyLevel<TEntity> for a tree with a nullable long foreign key to the same entity and a stored int level. Expose the level as a getter with [DefaultValue(0), DatabaseGenerated(DatabaseGeneratedOption.Computed)]. Import Blueprint.Entities.Triggers.PreparedTriggers and place this method inside Category.
/// <summary>Defines the trigger that maintains the category hierarchy levels.</summary>/// <returns>The prepared hierarchy-level trigger.</returns>publicoverrideList<BlueprintEntityTrigger>getDatabaseTriggers(){return[newPreparedTrigger_MaintainHierarchyLevel<Category>("TR_Categories_Level",nameof(ParentID),nameof(Level))];}
Register Category to install its trigger. The first installation calculates levels for existing rows in the same transaction that creates the trigger. An existing cycle causes installation to roll back.
A root has level zero. Inserting a node or changing its parent updates the depth of the affected subtree in the same transaction. Multi-row operations use the final parent relationships, including moves that affect overlapping subtrees. A cyclic change fails and rolls back. Ordinary edits to unrelated columns leave the levels in place.