Структура 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 nullNothingnullptrunitпустая ссылка (Nothing в Visual Basic).
Открытое свойствоСтатический элемент Null Gets a SqlHierarchyId with a hierarchy identification of nullNothingnullptrunitпустая ссылка (Nothing в Visual Basic).

В начало

Методы

  Имя Описание
Открытый метод 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

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.

См. также

Справочник