Resrcify.SharedKernel.Repository 4.0.0

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

Resrcify.SharedKernel.Repository

Resrcify.SharedKernel.Repository provides repository primitives and specification-based query support for aggregate roots.

Table of Contents

What you get

  • Repository abstractions in Resrcify.SharedKernel.Abstractions.Repository.
  • Base repository primitives in Primitives/.
  • Specification pattern support through:
    • Specification<TEntity, TId>
    • SpecificationEvaluator

Prerequisites

  • .NET 10 SDK.
  • Entity Framework Core in your consuming project.

Install

Option A: Project reference

<ProjectReference Include="..\path\to\Resrcify.SharedKernel.Repository.csproj" />

Option B: NuGet package

<PackageReference Include="Resrcify.SharedKernel.Repository" Version="<latest>" />

CLI:

dotnet add package Resrcify.SharedKernel.Repository

Quick Start

Register your concrete repository type in DI:

services.AddScoped<ICompanyRepository, CompanyRepository>();

Usage guide

Repository contract

IRepository<TEntity, TId> has what every repository needs: GetByIdAsync and FirstOrDefaultAsync (returning the aggregate, or null), GetAllAsync, FindAsync, ExistsAsync, AddAsync, Remove. A per-aggregate interface derives from it and adds only the queries its handlers need:

using Resrcify.SharedKernel.Abstractions.Repository;

public interface ICompanyRepository
    : IRepository<Company, CompanyId>
{
    Task<Company?> GetCompanyWithContactsAsync(
        CompanyId companyId,
        CancellationToken cancellationToken = default);
}

Repository implementation

internal sealed class CompanyRepository(
    AppDbContext context)
    : Repository<AppDbContext, Company, CompanyId>(context), ICompanyRepository
{
    public Task<Company?> GetCompanyWithContactsAsync(
        CompanyId companyId,
        CancellationToken cancellationToken = default)
        => Context.Companies
            .Include(x => x.Contacts)
            .FirstOrDefaultAsync(x => x.Id == companyId, cancellationToken);
}

Not found is the handler's decision

A fetch returns null when there is nothing; whether that is an error depends on the use case (a 404 for "get", the normal path for "create if missing"). The handler turns it into its own error:

var company = await companies
    .GetCompanyWithContactsAsync(command.CompanyId, cancellationToken)
    .ToResultAsync(() => DomainErrors.Company.NotFound(command.CompanyId.Value));
if (company.IsFailure)
    return company;

ToResultAsync(error) takes the error itself; ToResultAsync(() => error) makes it only when nothing was found, which saves formatting its message on every successful fetch. ToResult does the same for a value you already have.

Specification usage

var specification = new ActiveCompaniesSpecification();

IEnumerable<Company> companies = await repository.FindAsync(
    specification,
    cancellationToken);

Common issues

  • If includes/order clauses are ignored, verify they are defined on the specification and passed through evaluator.
  • If generic constraints fail, ensure entity types implement the expected aggregate-root contracts.
  • If queries are slow, evaluate specification complexity and EF tracking settings.

Sample project

See samples/Resrcify.SharedKernel.WebApiExample for repository and specification usage in an application flow.

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

Showing the top 1 NuGet packages that depend on Resrcify.SharedKernel.Repository:

Package Downloads
Resrcify.SharedKernel.PerformanceTests

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 21 10/13/2026
3.0.0 135 10/3/2026
2.2.0 133 9/13/2026
2.1.1 1,323 6/8/2026
2.1.0 136 5/24/2026
2.0.0 136 5/22/2026
1.16.3 200 5/7/2026
1.16.2 129 5/7/2026
1.16.1 117 5/7/2026
1.16.0 128 5/7/2026
1.15.0 202 4/18/2026
1.14.0 289 10/15/2025
1.13.0 338 6/27/2025
1.12.0 371 4/16/2025
1.11.0 290 4/15/2025
1.10.8 236 4/11/2025
1.10.7 254 4/9/2025
1.10.3 274 4/6/2025
1.10.2 244 4/6/2025
1.10.1 359 3/23/2025
Loading failed