蠢货之对闭包表的扩展

在sql反模式中,提到了闭包表,它只有两个字段。

public class Tree

{

/// <summary>
/// 祖先
/// </summary>
public int Ancestor { get; set; }

/// <summary>
/// 子孙
/// </summary>
public int Descendant { get; set; }

/// <summary>
/// 层级
/// </summary>
public int PathLength { get; set; }

/// <summary>
/// 顺序同级
/// </summary>
public int PathOrder { get; set; }

/// <summary>
/// 父级
/// </summary>
public int ParentId { get; set; }

}

增加的字段的作用。

PathLength 当前的结点在一棵树的层数。

ParentId 当前的结点的血亲父级。有利于画树。

 

posted @ 2021-01-29 15:44  forhells  阅读(103)  评论(0编辑  收藏  举报