DotNetQuery.Extensions.DependencyInjection 1.2.0

dotnet add package DotNetQuery.Extensions.DependencyInjection --version 1.2.0
                    
NuGet\Install-Package DotNetQuery.Extensions.DependencyInjection -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetQuery.Extensions.DependencyInjection" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetQuery.Extensions.DependencyInjection" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="DotNetQuery.Extensions.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetQuery.Extensions.DependencyInjection --version 1.2.0
                    
#r "nuget: DotNetQuery.Extensions.DependencyInjection, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetQuery.Extensions.DependencyInjection@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetQuery.Extensions.DependencyInjection&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=DotNetQuery.Extensions.DependencyInjection&version=1.2.0
                    
Install as a Cake Tool

DotNet Query

Build codecov

A TanStack Query-inspired async data fetching and state management library for .NET and Blazor.

DotNet Query brings the battle-tested data-fetching patterns of TanStack Query to the .NET ecosystem. It gives you predictable loading, error, and success states out of the box — powered by Rx.NET observables, so everything is composable, lazy, and reactive by default.

Features

  • Queries — fetch async data with automatic caching, background refetching, and stale-while-revalidate semantics
  • Mutations — execute data-modifying operations with lifecycle callbacks and automatic cache invalidation on success
  • Reactive state — built on Rx.NET, every query and mutation exposes IObservable streams for composable async pipelines
  • Smart caching — configurable stale time and cache time control when data is re-fetched and when it is evicted
  • Query deduplication — identical keys share a single cached query instance; no redundant requests
  • Retry logic — exponential backoff out of the box; plug in your own strategy via IRetryHandler
  • Observability — OTel-compatible distributed tracing (ActivitySource), metrics (Meter), and structured logging (ILogger) using only BCL APIs; no OpenTelemetry package required in the library
  • Blazor components<Suspense> and <Transition> components for declarative query rendering
  • CSR / SSR supportQueryExecutionMode controls Singleton (WebAssembly) vs Scoped (Server-Side Rendering) DI lifetime
  • DI integration — first-class support for Microsoft.Extensions.DependencyInjection

Installation

# Core library — always required
dotnet add package DotNetQuery.Core

# DI integration
dotnet add package DotNetQuery.Extensions.DependencyInjection

# Blazor components
dotnet add package DotNetQuery.Blazor

Documentation

Full guides, examples, and API reference are available here.

AI agents / LLMs: a single-file reference covering the full public API, all patterns, and architecture notes is available at /llms.txt.

Quick Start

// Program.cs
builder.Services.AddDotNetQuery(options =>
{
    options.StaleTime = TimeSpan.FromMinutes(1);
});
// Create a query
var query = queryClient.CreateQuery(new QueryOptions<int, UserDto>
{
    KeyFactory = id => QueryKey.From("users", id),
    Fetcher    = (id, ct) => userService.GetByIdAsync(id, ct),
});

query.SetArgs(42);

query.Success.Subscribe(user => Console.WriteLine($"Hello, {user.Name}!"));
query.Failure.Subscribe(error => Console.WriteLine($"Oops: {error.Message}"));
// Create a mutation
var mutation = queryClient.CreateMutation(new MutationOptions<CreateUserRequest, UserDto>
{
    Mutator        = (req, ct) => userService.CreateAsync(req, ct),
    InvalidateKeys = [QueryKey.From("users")],
    OnSuccess      = (_, user) => Console.WriteLine($"Created {user.Name}"),
});

mutation.Execute(new CreateUserRequest { Name = "Alice" });

<Suspense Query="query">
    <Content Context="user"><p>Hello, @user.Name!</p></Content>
    <Loading><p>Loading...</p></Loading>
    <Failure Context="error"><p>Error: @error.Message</p></Failure>
</Suspense>

Contributing

Contributions are welcome! Please see the Contributing guide for setup instructions, coding conventions, and the PR workflow. For bugs and feature requests, open an issue.

License

MIT — Copyright (c) 2026 Patrick Sachmann

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 69 5/27/2026
1.1.0 90 5/21/2026
1.0.0 91 5/20/2026
1.0.0-beta.10 47 5/19/2026
1.0.0-beta.9 58 4/14/2026
1.0.0-beta.8 57 4/11/2026
1.0.0-beta.7 56 4/11/2026
1.0.0-beta.6 61 4/11/2026
1.0.0-beta.5 53 4/11/2026
1.0.0-beta.4 60 4/11/2026
1.0.0-beta.3 62 4/10/2026
1.0.0-beta.2 55 4/10/2026
1.0.0-beta.0 55 4/10/2026
0.0.0-alpha.0.11 113 3/28/2026
0.0.0-alpha.0.10 105 3/28/2026