SqlHierarchyId 结构

The SqlHierarchyId type represents a position in a hierarchical structure, specifying depth and breadth.

命名空间:  Microsoft.SqlServer.Types
程序集:  Microsoft.SqlServer.Types(在 Microsoft.SqlServer.Types.dll 中)

语法

声明
<SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered := True,  _
    MaxByteSize := , Name := "SqlHierarchyId")> _
<CLSCompliantAttribute(True)> _
Public Structure SqlHierarchyId _
    Implements IBinarySerialize, INullable, IComparable
用法
Dim instance As SqlHierarchyId
[SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = "SqlHierarchyId")]
[CLSCompliantAttribute(true)]
public struct SqlHierarchyId : IBinarySerialize, 
    INullable, IComparable
[SqlUserDefinedTypeAttribute(Format::UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = L"SqlHierarchyId")]
[CLSCompliantAttribute(true)]
public value class SqlHierarchyId : IBinarySerialize, 
    INullable, IComparable
[<SealedAttribute>]
[<SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = "SqlHierarchyId")>]
[<CLSCompliantAttribute(true)>]
type SqlHierarchyId =  
    struct
        interface IBinarySerialize
        interface INullable
        interface IComparable
    end
JScript 支持使用结构,但不支持声明新结构。

SqlHierarchyId 类型公开以下成员。

属性

  名称 说明
公共属性 IsNull Gets a value indicating whether the SqlHierarchyId is nullNothingnullptrunitnull 引用(在 Visual Basic 中为 Nothing).
公共属性静态成员 Null Gets a SqlHierarchyId with a hierarchy identification of nullNothingnullptrunitnull 引用(在 Visual Basic 中为 Nothing).

页首

方法

  名称 说明
公共方法 CompareTo(Object) Returns a value indicating the results of a comparison between a SqlHierarchyId and an object.
公共方法 CompareTo(SqlHierarchyId) Returns a value indicating the results of a comparison between two SqlHierarchyId nodes.
公共方法 Equals Evaluates whether SqlHierarchyId and obj are equal. (覆盖 ValueType. . :: . .Equals(Object)。)
受保护方法 Finalize (从 Object 继承。)
公共方法 GetAncestor Retrieves the SqlHierarchyId node n levels up the hierarchical tree.
公共方法 GetDescendant Gets the value of a descendant SqlHierarchyId node that is greater than child1 and less than child2.
公共方法 GetHashCode Gets a hash of the path from the root node of the hierarchy tree to the SqlHierarchyId node. (覆盖 ValueType. . :: . .GetHashCode() () () ()。)
公共方法 GetLevel Gets a value indicating the level of the SqlHierarchyId node in the hierarchical tree.
公共方法 GetReparentedValue Gets a value representing the ___location of a new SqlHierarchyId node that has a path from newRoot equal to the path from oldRoot to this, effectively moving this to the new ___location.
公共方法静态成员 GetRoot Gets a value representing the root SqlHierarchyId node of the hierarchy.
公共方法 GetType (从 Object 继承。)
公共方法 IsDescendantOf Gets a value indicating whether the SqlHierarchyId node is the descendant of the parent.
受保护方法 MemberwiseClone (从 Object 继承。)
公共方法静态成员 Parse Converts the canonical string representation of a SqlHierarchyId node to a SqlHierarchyId value.
公共方法 Read Reads from a specified binary reader into a SqlHierarchyId.
公共方法 ToString Returns the canonical string representation of a SqlHierarchyId node from a SqlHierarchyId value. (覆盖 ValueType. . :: . .ToString() () () ()。)
公共方法 Write Writes a SqlHierarchyId to a specified binary writer.

页首

运算符

  名称 说明
公共运算符静态成员 Equality Evaluates whether two SqlHierarchyId nodes are equal.
公共运算符静态成员 GreaterThan Evaluates whether one specified SqlHierarchyId node is greater than another.
公共运算符静态成员 GreaterThanOrEqual Evaluates whether one specified SqlHierarchyId node is greater than or equal to another.
公共运算符静态成员 Inequality Evaluates whether two SqlHierarchyId nodes are unequal.
公共运算符静态成员 LessThan Evaluates whether one specified SqlHierarchyId node is less than another.
公共运算符静态成员 LessThanOrEqual Evaluates whether one specified SqlHierarchyId node is less than or equal to another.

页首

注释

This type provides the following benefits for storing hierarchical information:

  • Very compact data storage.

  • Depth-first comparison. Indexes on this type are in depth-first order, and nodes close to each other in a depth-first traversal are stored near each other.

  • Support for arbitrary insertions and deletions.

  • A limitation of this type is that a single instance of the hierarchy data type can be no larger than 892 bytes. Hierarchies that possess too many levels to fit within this limitation must use a different data type.

The HierarchyId type is available to CLR clients as the SqlHierarchyId data type.

示例

DECLARE @employee hierarchyid
SELECT @employee = OrgNode FROM HumanResources.EmployeeDemo
  WHERE LoginID = 'adventure-works\dylan0'

SELECT * FROM HumanResources.EmployeeDemo
WHERE @employee.IsDescendantOf(OrgNode) = 1

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。不保证所有实例成员都是线程安全的。