Table of Contents

Class QueryKey

Namespace
Velvet
Assembly
Velvet.Docs.dll

Identifies an entry in a QueryClient's cache: TanStack Query's queryKey array. Two keys are equal when they hold the same number of parts and each pair of parts is equal under object.Equals(object, object), so a key rebuilt every render with equal parts names the same entry, and a string, a boxed number or a record or tuple of such values compares by content. A part that is itself a QueryKey compares the same way. A part that is a collection whose type keeps object's own Equals compares by what it holds: an array or a list element by element, in order, as v5's structural hash compares an array; a dictionary by key and value whatever order the entries were added in, as v5 sorts an object's keys before hashing it; a set by element, in any order. A collection type that defines its own equality keeps it.

public sealed class QueryKey
Inheritance
object
QueryKey

Remarks

The parts are copied when the key is built, so editing the array passed in afterwards does not move the key. A part whose equality or hash code changes after the key is built — a mutable collection, for instance — is outside that guarantee. A record or a tuple compares by its members' own Equals, so a collection held inside one compares by reference and names a new entry whenever it is rebuilt: give the collection a key part of its own. A collection part is enumerated when the key is built and again on every comparison, so pass a materialised collection rather than a lazy query.

InvalidateQueries(QueryKey?) reads its key as a filter, v5's partialMatchKey: the filter's parts lead the key's, and a filter part that is an array or a list matches an array or a list that starts with it, one that is a dictionary matches a dictionary holding at least its entries, each value matched the same way.

Constructors

QueryKey(params object?[])

Builds a key from its parts, in order: new QueryKey("todos", id).

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

Equals(QueryKey?)

Indicates whether the current object is equal to another object of the same type.

GetHashCode()

Serves as the default hash function.

ToString()

Returns a string that represents the current object.