Freigeben über


SqlHierarchyId-Struktur

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

Namespace:  Microsoft.SqlServer.Types
Assembly:  Microsoft.SqlServer.Types (in Microsoft.SqlServer.Types.dll)

Syntax

'Declaration
<CLSCompliantAttribute(True)> _
<SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered := True,  _
    MaxByteSize := , Name := "SqlHierarchyId")> _
Public Structure SqlHierarchyId _
    Implements IBinarySerialize, INullable, IComparable
'Usage
Dim instance As SqlHierarchyId
[CLSCompliantAttribute(true)]
[SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = "SqlHierarchyId")]
public struct SqlHierarchyId : IBinarySerialize, 
    INullable, IComparable
[CLSCompliantAttribute(true)]
[SqlUserDefinedTypeAttribute(Format::UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = L"SqlHierarchyId")]
public value class SqlHierarchyId : IBinarySerialize, 
    INullable, IComparable
[<SealedAttribute>]
[<CLSCompliantAttribute(true)>]
[<SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered = true, 
    MaxByteSize = , Name = "SqlHierarchyId")>]
type SqlHierarchyId =  
    struct 
        interface IBinarySerialize 
        interface INullable 
        interface IComparable 
    end
JScript unterstützt die Verwendung von Strukturen, aber nicht die Deklaration neuer Strukturen.

Der SqlHierarchyId-Typ macht folgende Elemente verfügbar.

Eigenschaften

  Name Beschreibung
Öffentliche Eigenschaft IsNull Gets a value indicating whether the SqlHierarchyId is nullein NULL-Verweis (Nothing in Visual Basic).
Öffentliche EigenschaftStatisches Element Null Gets a SqlHierarchyId with a hierarchy identification of nullein NULL-Verweis (Nothing in Visual Basic).

Zum Anfang

Methoden

  Name Beschreibung
Öffentliche Methode CompareTo(Object) Returns a value indicating the results of a comparison between a SqlHierarchyId and an object.
Öffentliche Methode CompareTo(SqlHierarchyId) Returns a value indicating the results of a comparison between two SqlHierarchyId nodes.
Öffentliche Methode Equals Evaluates whether SqlHierarchyId and obj are equal. (Überschreibt ValueType.Equals(Object).)
Öffentliche Methode GetAncestor Retrieves the SqlHierarchyId node n levels up the hierarchical tree.
Öffentliche Methode GetDescendant Gets the value of a descendant SqlHierarchyId node that is greater than child1 and less than child2.
Öffentliche Methode GetHashCode Gets a hash of the path from the root node of the hierarchy tree to the SqlHierarchyId node. (Überschreibt ValueType.GetHashCode().)
Öffentliche Methode GetLevel Gets a value indicating the level of the SqlHierarchyId node in the hierarchical tree.
Öffentliche Methode 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.
Öffentliche MethodeStatisches Element GetRoot Gets a value representing the root SqlHierarchyId node of the hierarchy.
Öffentliche Methode GetType (Geerbt von Object.)
Öffentliche Methode IsDescendantOf Gets a value indicating whether the SqlHierarchyId node is the descendant of the parent.
Öffentliche MethodeStatisches Element Parse Converts the canonical string representation of a SqlHierarchyId node to a SqlHierarchyId value.
Öffentliche Methode Read Reads from a specified binary reader into a SqlHierarchyId.
Öffentliche Methode ToString Returns the canonical string representation of a SqlHierarchyId node from a SqlHierarchyId value. (Überschreibt ValueType.ToString().)
Öffentliche Methode Write Writes a SqlHierarchyId to a specified binary writer.

Zum Anfang

Operatoren

  Name Beschreibung
Öffentlicher OperatorStatisches Element Equality Evaluates whether two SqlHierarchyId nodes are equal.
Öffentlicher OperatorStatisches Element GreaterThan Evaluates whether one specified SqlHierarchyId node is greater than another.
Öffentlicher OperatorStatisches Element GreaterThanOrEqual Evaluates whether one specified SqlHierarchyId node is greater than or equal to another.
Öffentlicher OperatorStatisches Element Inequality Evaluates whether two SqlHierarchyId nodes are unequal.
Öffentlicher OperatorStatisches Element LessThan Evaluates whether one specified SqlHierarchyId node is less than another.
Öffentlicher OperatorStatisches Element LessThanOrEqual Evaluates whether one specified SqlHierarchyId node is less than or equal to another.

Zum Anfang

Hinweise

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.

Beispiele

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

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

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic)-Elemente dieses Typs sind Threadsicher. Für Instanzelemente wird die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

Microsoft.SqlServer.Types-Namespace