FunqTypes.AspNetCore 1.2.0

dotnet add package FunqTypes.AspNetCore --version 1.2.0
                    
NuGet\Install-Package FunqTypes.AspNetCore -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="FunqTypes.AspNetCore" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FunqTypes.AspNetCore" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="FunqTypes.AspNetCore" />
                    
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 FunqTypes.AspNetCore --version 1.2.0
                    
#r "nuget: FunqTypes.AspNetCore, 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.
#addin nuget:?package=FunqTypes.AspNetCore&version=1.2.0
                    
Install FunqTypes.AspNetCore as a Cake Addin
#tool nuget:?package=FunqTypes.AspNetCore&version=1.2.0
                    
Install FunqTypes.AspNetCore as a Cake Tool

🌐 FunqTypes.AspNet - Helpers for Asp.Net

🎯 What is FunqTypes?

FunqTypes is a set of functional types and helpers for .NET that brings null-safety, error handling and composition to C# applications. It provides:

  • Result<T> type - Monadic error handling with Ok/Fail or Gotcha/Oops alternative aliases
  • Option<T> type - Null-safe optional values with Some/None or Yeah/Nah alternative aliases
  • LINQ & FP Support - Fluent mappings, binding, filtering
  • Zero Overhead - Efficient readonly record struct implementation

Standard Usage (Default 200 OK)

[HttpGet("{id}")]
public async Task<IActionResult> GetAccount(int id)
{
    return await GetAccountById(id).ToActionResultAsync();
}
  • Returns 200 OK on success.
  • Returns 400 Bad Request on failure.

201 Created for POST Requests

[HttpPost]
public async Task<IActionResult> CreateAccount([FromBody] CreateAccountRequest request)
{
    return await CreateAccount(request).ToActionResultAsync(HttpStatusCode.Created);
}
  • Returns 201 Created on success.
  • Returns 400 Bad Request on failure.

Custom Error Mapping with HttpStatusCode

private static HttpStatusCode MapErrorToStatusCode(ValidationError error) =>
    error.Code switch
    {
        "NOT_FOUND" => HttpStatusCode.NotFound,
        "INVALID_INPUT" => HttpStatusCode.UnprocessableEntity,
        "UNAUTHORIZED" => HttpStatusCode.Unauthorized,
        _ => HttpStatusCode.BadRequest
    };

Then, use it in the controller:

[HttpPut("{id}")]
public async Task<IActionResult> UpdateAccount(int id, [FromBody] UpdateAccountRequest request)
{
    return await UpdateAccount(id, request).ToActionResultAsync(HttpStatusCode.OK, MapErrorToStatusCode);
}
  • 404 Not Found for NOT_FOUND
  • 422 Unprocessable Entity for INVALID_INPUT
  • 401 Unauthorized for UNAUTHORIZED
  • 400 Bad Request for other errors
Product 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.  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. 
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 63 4/4/2025