AnyResults 10.0.0
dotnet add package AnyResults --version 10.0.0
NuGet\Install-Package AnyResults -Version 10.0.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="AnyResults" Version="10.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnyResults" Version="10.0.0" />
<PackageReference Include="AnyResults" />
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 AnyResults --version 10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AnyResults, 10.0.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 AnyResults@10.0.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=AnyResults&version=10.0.0
#tool nuget:?package=AnyResults&version=10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<a href="https://www.nuget.org/packages/AnyResults/" target="_blank"><img src="https://img.shields.io/nuget/v/AnyResults.svg" alt="NuGet" /></a> <a href="https://www.nuget.org/packages/AnyResults" target="_blank"><img src="https://img.shields.io/nuget/dt/AnyResults"/></a>
AnyResults
Unified result handling & data paging for .NET projects. Fast, simple, and clean.
Key Features
Result/Result<T>– Represent success or failure of any operation. Avoid throwing exceptions unnecessarily.PagedResult<T>– Easily page your IQueryable data. Comes with extensions for LINQ.PaginationQuery– Specify page number, page size, and sorting for PagedResult.
dotnet add package AnyResults
⭐ Result Examples
1. Basic Result:
var result = Result.Ok().WithMessage("Operation successful");
if (result.IsSuccess)
{
Console.Write(result.Data); // "Operation successful"
}
2. Generic Result:
User user = new() { Name = "Tom" };
var result = Result.Ok(user);
if (result.IsSuccess)
{
Console.Write(result.Data.Name); // Tom
}
Result/Result<T>– Represent success or failure of any operation. Supports implicit conversion betweenResultandResult<T>to simplify handling generic and non-generic results.
public Result<Todo> Update(Guid id, UpdateTodoInputModel todoModel)
{
if (todoModel == null)
return Result.Fail("Todo cannot be null."); // <-- Result
Todo todo = FindById(id);
try
{
// update database command.
}
catch (Exception ex)
{
return Result.Fail(ex); // <-- Result
}
return Result.Ok(todo).WithMessage(message: "Todo created successfully!"); // <-- Result
}
Fail:
var result = Result.Fail("An error was occurred!");
if (result.IsSuccess == false)
{
Console.WriteLine(result.Messages[0]); // An error was occurred!
}
⭐ PagedQuery Examples:
1. PagedResult with IQueryable
public async Task<PagedResult<Users>> PageByBusinessIdAsync(PaginationQuery page)
{
var query = context.Users.AsQueryable();
var paged = await query.ToPagedResultAsync(page, ct);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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.
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.8)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.