DcsvIo.D2.Handler.Repo.Abstractions 0.1.1

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

DcsvIo.D2.Handler.Repo.Abstractions

Vocabulary for repo-flavored handlers — what app-layer code touches when it needs to discriminate database failures (unique violation, FK violation, deadlock, concurrency conflict, connection failure, etc.). Pure abstractions: zero infrastructure dependencies. EF Core, Npgsql, and any provider knowledge live in sibling packages (DcsvIo.D2.Handler.Repo, DcsvIo.D2.Handler.Repo.Postgres).

Install

dotnet add package DcsvIo.D2.Handler.Repo.Abstractions

Public API

Type Role
DbFailureKind Enum — ConcurrencyConflict / UniqueViolation / ForeignKeyViolation / NotNullViolation / CheckViolation / Timeout / Deadlock / ConnectionFailure
IDbExceptionClassifier Provider seam — DbFailureKind? Classify(Exception)
DbErrorCodes String constants (UNIQUE_VIOLATION, FOREIGN_KEY_VIOLATION, etc.) used as D2Result.ErrorCode values
D2Result DB factories Static C# 14 extension factories — D2Result.UniqueViolation(), .ConcurrencyConflict(), .DbDeadlock(), etc. (non-generic + generic)
DB booleans C# 14 instance extension properties — result.IsUniqueViolation, result.IsConcurrencyConflict, result.IsTransientDbFailure, etc.

Emitting + discriminating DB failures

Handler code returns typed DB failures via the extension factories:

return D2Result<User>.UniqueViolation(
    messages: [TK.Auth.Errors.EMAIL_ALREADY_TAKEN],
    inputErrors: [new InputError("email", "EMAIL_ALREADY_TAKEN")]);

Caller code discriminates via the boolean discriminators:

var result = await createUser.HandleAsync(input);
if (result.IsUniqueViolation)
    return Conflict(result.Messages);
if (result.IsTransientDbFailure)
    return await retryPolicy.RetryAsync(() => createUser.HandleAsync(input));
if (result.IsConcurrencyConflict)
    return await ReloadAndMergeAsync(input);

The IsTransientDbFailure predicate is a roll-up — IsDbDeadlock || IsDbTimeout || IsDbConnectionFailure. IsConcurrencyConflict is intentionally excluded — concurrency conflicts need reload-then-merge logic, not a blind retry.

IsTransientDbFailure is a separate axis from the built-in IsTransientRetryable (IsServiceUnavailable || IsRateLimited) on D2Result in the result lib. They live in separate libs because not every consumer of D2Result deals with a database; the DB roll-up only loads when the consumer references this package. A generic retry policy that wants to catch BOTH HTTP-flavored AND DB-flavored transient failures should check the union: result.IsTransientRetryable || result.IsTransientDbFailure.


Default messages

Each factory accepts an optional messages parameter; when omitted, the generic fallback from TK.Common.Errors.* is used:

Factory Default TKMessage
ConcurrencyConflict() TK.Common.Errors.CONCURRENCY_CONFLICT
UniqueViolation() TK.Common.Errors.UNIQUE_VIOLATION
ForeignKeyViolation() TK.Common.Errors.FOREIGN_KEY_VIOLATION
NotNullViolation() TK.Common.Errors.NOT_NULL_VIOLATION
CheckViolation() TK.Common.Errors.CHECK_VIOLATION
DbTimeout() TK.Common.Errors.DB_TIMEOUT
DbDeadlock() TK.Common.Errors.DB_DEADLOCK
DbConnectionFailure() TK.Common.Errors.DB_CONNECTION_FAILURE

These defaults are deliberately generic ("This value is already in use"). Handlers that know the constraint identity should override the message — e.g. [TK.Auth.Errors.EMAIL_ALREADY_TAKEN] instead — and attach an InputError so the form UI can highlight the offending field.


Status code mapping

Factory HTTP status
ConcurrencyConflict / UniqueViolation / ForeignKeyViolation / DbDeadlock 409 Conflict
NotNullViolation / CheckViolation 400 Bad Request
DbTimeout / DbConnectionFailure 503 Service Unavailable

Dependencies

  • DcsvIo.D2.Result — base D2Result type that the factories extend
  • DcsvIo.D2.I18nTKMessage + TK codegen entry point

Zero external NuGet packages. No EF Core, no Npgsql.


  • DcsvIo.D2.Handler.RepoBaseRepoHandler consumes the classifier interface
  • DcsvIo.D2.Handler.Repo.Postgres — PostgreSQL classifier implementation
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DcsvIo.D2.Handler.Repo.Abstractions:

Package Downloads
DcsvIo.D2.Handler.Repo.Postgres

PostgreSQL IDbExceptionClassifier implementation for D2, plugging Npgsql failure classification into BaseRepoHandler.

DcsvIo.D2.Handler.Repo

EF-flavored BaseRepoHandler for D2 — converts database exceptions captured during execution into typed D2Result failures.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 124 7/17/2026
0.1.0 129 7/17/2026