SLR.Results
1.20230910.103855
See the version list below for details.
dotnet add package SLR.Results --version 1.20230910.103855
NuGet\Install-Package SLR.Results -Version 1.20230910.103855
<PackageReference Include="SLR.Results" Version="1.20230910.103855" />
<PackageVersion Include="SLR.Results" Version="1.20230910.103855" />
<PackageReference Include="SLR.Results" />
paket add SLR.Results --version 1.20230910.103855
#r "nuget: SLR.Results, 1.20230910.103855"
#addin nuget:?package=SLR.Results&version=1.20230910.103855
#tool nuget:?package=SLR.Results&version=1.20230910.103855
Results
SLR.Results is a .NET library that is designed to tackle a common issue. It presents an object that reflects the success or failure of an operation, as opposed to utilizing or raising exceptions.
You can install SLR.Results with NuGet:
Install-Package SLR.Results
Key Features
- Works in most .NET Projects
- Choose from Result, Result<T>, ListResult<T> to cater for all use cases
- Store multiple errors or validation errors in one Result object
- Store Error or Success objects instead of only error messages in string format
- Allows uniformity in your code or anyone that needs to consume it
- ApiResponseHelper to have uniform API Responses in Controllers
- ListResult<T> has built-in capability for paging using PagingExtensions
Return a Result
A Result can store multiple Errors, NotFound or ValidationErrors.
// return a result which indicates success
return Result.Success();
// return a result of a type which indicates success
return Result<Sample>.Success(new Sample());
//return a list result which indicates success
var entities = this.DatabaseContext.Samples.Select(x => x).AsNoTracking()
var count = await entities.Count();
var paged = await entities.ApplyPaging(model.PagingArgs).ToListAsync(cancellationToken);
return ListResult<Sample>.Success(paged, count);
// return a result which indicates failure
return Result.Failure("Error");
return Result<Sample>.Failure("Error");
Result on the API
This will handle 400, 404, 500 and 200
return ApiResponseHelper.ResponseOutcome(await this.Mediator.Send(new ExampleQuery(), cancellationToken), this)
.NET Targeting
.NET 6.0, .NET 7.0 and .NET 8.0
Contributors
Thanks to all the contributors and to all the people who gave feedback!
<a href="https://github.com/stianleroux/results/graphs/contributors"> <img src="https://contrib.rocks/image?repo=stianleroux/results" /> </a>
Copyright
Copyright (c) Stian Le Roux. See LICENSE for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Http.Polly (>= 7.0.0-preview.6.22330.3)
-
net7.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Http.Polly (>= 7.0.0-preview.6.22330.3)
-
net8.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Http.Polly (>= 7.0.0-preview.6.22330.3)
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.20250401.212636 | 141 | 4/1/2025 |
1.20250401.212431 | 137 | 4/1/2025 |
1.20250401.212042 | 143 | 4/1/2025 |
1.20250401.210635 | 138 | 4/1/2025 |
1.20250401.205958 | 138 | 4/1/2025 |
1.20250401.205654 | 138 | 4/1/2025 |
1.20250401.203237 | 140 | 4/1/2025 |
1.20250401.202933 | 138 | 4/1/2025 |
1.20250401.202441 | 142 | 4/1/2025 |
1.20250401.202207 | 139 | 4/1/2025 |
1.20250401.201916 | 139 | 4/1/2025 |
1.20250401.200941 | 137 | 4/1/2025 |
1.20250401.200620 | 146 | 4/1/2025 |
1.20250401.200144 | 138 | 4/1/2025 |
1.20250401.194313 | 145 | 4/1/2025 |
1.20250401.194144 | 143 | 4/1/2025 |
1.20250201.91742 | 106 | 2/1/2025 |
1.20250201.91539 | 92 | 2/1/2025 |
1.20250201.83903 | 91 | 2/1/2025 |
1.20230910.104229 | 178 | 9/10/2023 |
1.20230910.103855 | 101 | 9/10/2023 |
1.20230910.103129 | 103 | 9/10/2023 |
1.20230910.100644 | 110 | 9/10/2023 |