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
<PackageReference Include="Bodatero.Result" Version="1.0.0.1" />
<PackageVersion Include="Bodatero.Result" Version="1.0.0.1" />
<PackageReference Include="Bodatero.Result" />
paket add Bodatero.Result --version 1.0.0.1
#r "nuget: Bodatero.Result, 1.0.0.1"
#:package Bodatero.Result@1.0.0.1
#addin nuget:?package=Bodatero.Result&version=1.0.0.1
#tool nuget:?package=Bodatero.Result&version=1.0.0.1
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:
- Performance - Exceptions are costly, as they involve stack unwinding and capturing detailed diagnostics.
- Predictability - Results clearly indicate success or failure without relying on catching exceptions.
- Cleaner Code - Avoids excessive try-catch blocks, making the business logic more readable.
- 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 | 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 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. |
-
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.