Alvecta.Foundation.Application.Ports 8.0.77

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alvecta.Foundation.Application.Ports --version 8.0.77
                    
NuGet\Install-Package Alvecta.Foundation.Application.Ports -Version 8.0.77
                    
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="Alvecta.Foundation.Application.Ports" Version="8.0.77" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Alvecta.Foundation.Application.Ports" Version="8.0.77" />
                    
Directory.Packages.props
<PackageReference Include="Alvecta.Foundation.Application.Ports" />
                    
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 Alvecta.Foundation.Application.Ports --version 8.0.77
                    
#r "nuget: Alvecta.Foundation.Application.Ports, 8.0.77"
                    
#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 Alvecta.Foundation.Application.Ports@8.0.77
                    
#: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=Alvecta.Foundation.Application.Ports&version=8.0.77
                    
Install as a Cake Addin
#tool nuget:?package=Alvecta.Foundation.Application.Ports&version=8.0.77
                    
Install as a Cake Tool

Alvecta.Foundation.Application.Ports

The driven-port persistence contracts of the Alvecta application layer: technology-agnostic interfaces that application services depend on and an infrastructure adapter (such as Alvecta.Foundation.Infrastructure.EF) implements.

It belongs to the Application.Ports layer. Ports face infrastructure, so unlike the contracts they speak the domain model (entities). The package has no dependencies.

Read and write are separate faces

Persistence is split into two sibling faces; neither inherits the other.

Face Scope Factory Repositories
Write IUnitOfWork: collects changes, commits them once with SaveChangesAsync IUnitOfWorkFactory<TUnitOfWork> IRepository<TEntity[, TKey]>, IAddOnlyRepository<TEntity>
Read IQuerySession: a disposable read window, nothing to commit IQuerySessionFactory<TQuerySession> IQueryableRepository<TEntity[, TKey]>
  • IRepository never exposes an IQueryable. It adds, updates and deletes through Add* / Update* / Delete* methods, and offers a few projection-only reads for making write decisions (ExistsAsync, GetSingleAsync, GetSingleOrDefaultAsync with a selector).
  • IQueryableRepository hands out IQueryable roots (Query, Where, ByKey) for server-side composition. Entities it returns are untracked: never change them.

Also in the package:

  • Persistence.MultiTenant.ITenantIdProvider<TTenantId> — the current tenant, or cross-tenant mode.
  • Persistence.DatabaseMigration.IDatabaseMigrator / IDatabaseMigrator<TMarker> — applies a database's migrations; the marker type tells several databases apart.
  • Persistence.KeyPredicate — builds the predicates behind the key lookups (EqualTo for one key, EqualToAny for several) from a key selector, so every implementation of the repositories, the EF-backed ones and the in-memory fake of Alvecta.Foundation.Application.Ports.Testing alike, looks entities up by the same expression.

Usage

dotnet add package Alvecta.Foundation.Application.Ports

Declare one unit of work and one query session per database in your *.Application.Ports project:

using Alvecta.Foundation.Application.Ports.Persistence.Querying;
using Alvecta.Foundation.Application.Ports.Persistence.UnitOfWork;

public interface IOrdersUnitOfWork : IUnitOfWork
{
    IRepository<Order, OrderId> Orders { get; }
}

public interface IOrdersQuerySession : IQuerySession
{
    IQueryableRepository<OrderView, OrderId> Orders { get; }
}

Depend on the factories from application services. Open one scope per operation:

public sealed class OrdersPersistenceService(IUnitOfWorkFactory<IOrdersUnitOfWork> unitOfWorkFactory)
{
    public async Task CancelAsync(OrderId orderId, CancellationToken cancellationToken)
    {
        await using var unitOfWork = await unitOfWorkFactory.CreateUnitOfWorkAsync(cancellationToken);

        await unitOfWork.Orders.UpdateSingleAsync(orderId, order => order.Cancel(), cancellationToken);

        await unitOfWork.SaveChangesAsync(cancellationToken);
    }
}

Alvecta.Foundation.Infrastructure.EF implements these ports over EF Core and registers the factories.

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.
  • net10.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Alvecta.Foundation.Application.Ports:

Package Downloads
Alvecta.Foundation.Infrastructure.EF

Package Description

Alvecta.Foundation.Infrastructure.EF.Testing

EF Core persistence test harness for read/write DbContext pairs (scalar schema parity, migrations drift, pinned migration scripts, projection-only read-face guarantees) as abstract xunit base classes, plus an in-memory Sqlite database (SqliteTestDatabase) for integration tests over the real contexts. Add thin sealed run-host subclasses in your own test project.

Alvecta.Foundation.Application.Ports.Testing

Fakes for testing code written against Alvecta.Foundation.Application.Ports: InMemoryQueryableRepository is an IQueryableRepository over a test's in-memory entities, with Where, ByKey, GetSingleAsync and ExistsAsync built on Query like the EF-backed repository; FixedTenantIdProvider is an ITenantIdProvider with a fixed current tenant. Reference it from a test project.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.6.96 59 11/25/2026
9.6.95 61 11/25/2026
9.6.94 96 11/24/2026
9.6.93 86 11/24/2026
9.5.92 94 11/24/2026
9.4.91 137 11/20/2026
9.3.90 148 11/13/2026
9.2.89 144 11/12/2026
9.1.88 141 11/11/2026
9.0.87 160 11/4/2026
9.0.86 147 11/4/2026
9.0.85 145 11/4/2026
9.0.84 151 11/4/2026
9.0.83 157 10/29/2026
9.0.82 156 10/29/2026
8.1.81 150 10/29/2026
8.0.80 145 10/28/2026
8.0.79 147 10/28/2026
8.0.78 145 10/28/2026
8.0.77 146 10/28/2026
Loading failed