OperationResultCore 4.1.0

Suggested Alternatives

Calabonga.Results

Additional Details

The new package is more flexible and has enormous performance compared to OperationResultCore

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

OperationResult

OperationResult is an implementation of RFC7807. In other words, it's simple wrapper for result operation for any returned data from backend, where you can add additional information about problem or other things.

"Частичная реализация" стандарта RFC7807, который определяет в документе следующее:

This document defines a "problem detail" as a way to carry machine- readable details of errors in a HTTP response to avoid the need to define new error response formats for HTTP APIs.

Суть в том, что если у вас есть API и в нем есть методы отдающие данные, например Product, то в результате успешного результата вы должны отдать сам объект Product. А вот если по какой-то причине вы не можете отдать конкретный объект (или объекты), тогда вы должные указать по какой причине вы не можете это сделать. Другими словами "детализировать проблему" (problem detail). А как это сделать как раз и описывает стандарт RFC7807.

Почему "Частичная реализация"? Потому что nuget-пакет и, соответственно, потребность в нем появилась задолго до появления стандарта. Постепенно, пакет трансформируется под стандарт, но это может занять некоторое время. Если у вас нет времени ждать, пишите свою реализацию или воспользуйтесь стандартами на платформе ASP.NET Core.

Версии

v4.1.0

  • Добавлена конструкция создания экземпляра сразу с Exception, но при этому с Result = null. Для этого добавлен метод WithException().
  • Добавлено несколько unit-тестов для WithException().

v4.0.2

  • Добавлена структура Empty для того, чтобы не требовался класс для создания объекта OperationResult. Тепер можно использовать Empty для создания OperationResult<T>, если не требуется никакой конкретный класс, но при этом остальные возможности востребованы.
  • Исправлены некоторые недочеты при публикации nuget-пакета.
  • Добавлено несколько unit-тестов.

Репозиторий

GitHub

Пакеты Nuget

Nuget OperationResult

Nuget OperationResultCore

Дополнительно

Статья в блоге 1

Статья в блоге 2

Видео YouTube

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 (6)

Showing the top 5 NuGet packages that depend on OperationResultCore:

Package Downloads
Calabonga.UnitOfWork.Controllers

Unit of Work implementation over ASP.NET Core Controllers

Calabonga.AspNetCore.Controllers

Unit of Work implementation for EntityFramework Core. Package based over the mediatr pattern (mediatr package used). For more information please see Calabonga.UnitOfWork package. Mediator pattern impementation.

Calabonga.EntityFrameworkCore

Simply Data Accesss Layer for EntityFramework with some helpfull features.

Calabonga.SpecRepositoryCore

Repository and Specification patterns implementations for EntityFrameworkCore with pagination and other sugar

Calabonga.EntityFrameworkCore.UnitOfWork.Framework

UnitOfWork for Microservices. All microservices in the system should and can use Unit of Work pattern. This package implements this pattern.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0 2,311 9/21/2023 4.1.0 is deprecated.
4.1.0-beta2 227 7/20/2023
4.1.0-beta1 170 7/12/2023
4.0.3 541 6/20/2023
4.0.2 501 6/11/2023
4.0.2-beta2 205 12/31/2022
4.0.2-beta1 187 12/31/2022
4.0.1 1,576 12/31/2022
4.0.0 855 8/22/2022
4.0.0-beta2 253 4/3/2022
4.0.0-beta1 224 4/2/2022
3.0.1 3,583 12/3/2021
3.0.0 4,691 1/26/2021
2.1.3 2,035 9/24/2020
2.1.2 3,136 4/6/2020
2.1.1 1,452 3/27/2020
2.1.0 674 3/24/2020
2.0.14 3,119 11/27/2019
2.0.13 640 11/13/2019
2.0.12 630 11/8/2019
2.0.11 677 10/31/2019
2.0.10 664 10/30/2019
2.0.9 650 10/30/2019
2.0.8 642 10/29/2019
2.0.7 1,497 10/22/2019
2.0.1 1,239 10/4/2019
2.0.0 630 10/2/2019
1.1.0 1,972 7/18/2019
1.0.1 2,434 11/20/2018
1.0.0 8,605 11/17/2017
1.0.0-beta1 1,204 11/16/2017

OperationResult.WithException added