Bodatero.Result 1.0.0.1

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

Bodatero.Result

Overview

Bodatero.Result is a domain package that provides a standardized way to handle operation results across an application. It encapsulates success and failure states, eliminating the need for throwing exceptions in expected scenarios such as validation errors.

This package serves as the foundation for other sub-packages, including Bodatero.Result.AspNetCore, which extends its capabilities for API responses.


Why Use Result<T> Instead of Exceptions?

✅ Benefits Over Throwing Exceptions:

  1. Performance - Exceptions are costly, as they involve stack unwinding and capturing detailed diagnostics.
  2. Predictability - Results clearly indicate success or failure without relying on catching exceptions.
  3. Cleaner Code - Avoids excessive try-catch blocks, making the business logic more readable.
  4. Encapsulation - Error details are stored in a structured format rather than being scattered across exception handling.

Usage

Using Result<T> in Business Logic

public class ProductService
{
    public Result<Product> CreateProduct(string name, string description)
    {
        if (string.IsNullOrWhiteSpace(name))
            return new Exception("Name must not be empty");
        if (string.IsNullOrWhiteSpace(description))
            return new Exception("Name must not be empty");

        var product = new Product { Name = name, Description = description };

        return product;
    }
}

This approach keeps the logic clear and prevents unnecessary exceptions from being thrown for validation failures.


Please support me with a donation on Patreon

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 was computed.  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 was computed.  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.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Bodatero.Result:

Package Downloads
Bodatero.Result.AspNetCore

The packge provides services for handling endpoints which are returning the Bodatero.Result type object

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.1 146 2/20/2025
1.0.0 123 2/19/2025