Table of Contents

Class QueryOptions<TArgs, TData>

Namespace
DotNetQuery.Core
Assembly
DotNetQuery.Core.dll

Configuration options for a single query created via CreateQuery<TArgs, TData>(QueryOptions<TArgs, TData>). Per-query settings override the global defaults set on QueryClientOptions.

public sealed record QueryOptions<TArgs, TData> : IEquatable<QueryOptions<TArgs, TData>> where TData : class

Type Parameters

TArgs

The type of the arguments passed to the fetcher.

TData

The type of the data returned by the fetcher. Constrained to reference types.

Inheritance
QueryOptions<TArgs, TData>
Implements
IEquatable<QueryOptions<TArgs, TData>>
Inherited Members

Properties

CacheTime

Overrides the global CacheTime. null uses the global default.

public TimeSpan? CacheTime { get; init; }

Property Value

TimeSpan?

DataComparer

Comparer used to determine whether newly fetched data is structurally equal to the previously cached value. When equal, the cached data reference is preserved and Success will not re-emit. Defaults to null, which falls back to Default (reference equality for classes, value equality for records and primitives).

public IEqualityComparer<TData>? DataComparer { get; init; }

Property Value

IEqualityComparer<TData>

Fetcher

The async function that fetches data for the given args. Receives a CancellationToken that is cancelled when the query is disposed or superseded.

public required Func<TArgs, CancellationToken, Task<TData>> Fetcher { get; init; }

Property Value

Func<TArgs, CancellationToken, Task<TData>>

InitialData

Data used to pre-populate the query result before the first fetch completes. The query is always treated as immediately stale when initial data is present, so a background fetch begins as soon as the first subscriber joins. Has no effect if the cache already holds a real entry for the derived key.

public TData? InitialData { get; init; }

Property Value

TData

IsEnabled

Whether the query is initially enabled. Defaults to true. Set to false to create a disabled-by-default query without needing to call SetEnabled(bool).

public bool IsEnabled { get; init; }

Property Value

bool

KeyFactory

A function that derives a QueryKey from the given args. Used to identify and share cache entries across queries with the same key.

public required Func<TArgs, QueryKey> KeyFactory { get; init; }

Property Value

Func<TArgs, QueryKey>

Name

A short, low-cardinality name used to tag metrics for this query (e.g. "users", "todos"). Metrics are never tagged with the full QueryKey — which typically includes per-entity arguments such as an id — because that would produce one time series per distinct argument value. When null, the first part of the derived QueryKey is used instead. Traces and log messages always carry the full key regardless of this setting. See IncludeQueryKeyInMetrics to opt back into per-key metrics.

public string? Name { get; init; }

Property Value

string

RefetchInterval

Overrides the global RefetchInterval. null uses the global default.

public TimeSpan? RefetchInterval { get; init; }

Property Value

TimeSpan?

RetryHandler

Overrides the global RetryHandler. null uses the global default.

public IRetryHandler? RetryHandler { get; init; }

Property Value

IRetryHandler

StaleTime

Overrides the global StaleTime. null uses the global default.

public TimeSpan? StaleTime { get; init; }

Property Value

TimeSpan?