AspNet.KickStarter.FunctionalResult
1.2.3
Prefix Reserved
dotnet add package AspNet.KickStarter.FunctionalResult --version 1.2.3
NuGet\Install-Package AspNet.KickStarter.FunctionalResult -Version 1.2.3
<PackageReference Include="AspNet.KickStarter.FunctionalResult" Version="1.2.3" />
paket add AspNet.KickStarter.FunctionalResult --version 1.2.3
#r "nuget: AspNet.KickStarter.FunctionalResult, 1.2.3"
// Install AspNet.KickStarter.FunctionalResult as a Cake Addin #addin nuget:?package=AspNet.KickStarter.FunctionalResult&version=1.2.3 // Install AspNet.KickStarter.FunctionalResult as a Cake Tool #tool nuget:?package=AspNet.KickStarter.FunctionalResult&version=1.2.3
AspNet.KickStarter.FunctionalResult
This library provides Result
, Result<T>
and Error
types, these types support implicit conversions for ease of use.
The Result
class provides Switch
, Match
and Bind
methods to conditionally perform actions depending on success or error of the result. They also provide access to the Value
or Error
values.
The Error
class supports FluentValidation errors and provides an AsHttpResult
method to produce a suitable IResult from a HTTP handler. For example:
var result = await _mediator.Send(new GetSomeQuery());
return result.Match(
success => Results.Ok(success),
error => error.AsHttpResult());
If the unsuccessful result contains a ValidationResult
then this will return Results.ValidationProblem
with the details, otherwise Results.Problem
Sample Usage
internal IResult GetDoubleAsync(double value)
{
var result = doubleService.GetDouble(value);
return result.Match(
success => Results.Ok(success),
error => error.AsHttpResult());
}
internal class DoubleService
{
public Result<double> GetDouble(double value)
{
try
{
return 2 * value;
}
catch (Exception ex)
{
return ex;
}
}
}
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 was computed. 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. |
-
net6.0
- FluentValidation (>= 11.9.1)
- MediatR (>= 12.2.0)
-
net8.0
- FluentValidation (>= 11.9.1)
- MediatR (>= 12.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AspNet.KickStarter.FunctionalResult:
Package | Downloads |
---|---|
AspNet.KickStarter
This simplifies the bootstrapping code to run a minimal API with optional AddIn support for Serilog, FluentValidation, OpenTelemetry and Swagger. |
|
AspNet.KickStarter.CQRS
This is a basic library of interfaces to use for CQRS commands and queries with MediatR. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.3 | 124 | 6/18/2024 |