Alvecta.Foundation.Application.Ports
9.4.91
See the version list below for details.
dotnet add package Alvecta.Foundation.Application.Ports --version 9.4.91
NuGet\Install-Package Alvecta.Foundation.Application.Ports -Version 9.4.91
<PackageReference Include="Alvecta.Foundation.Application.Ports" Version="9.4.91" />
<PackageVersion Include="Alvecta.Foundation.Application.Ports" Version="9.4.91" />
<PackageReference Include="Alvecta.Foundation.Application.Ports" />
paket add Alvecta.Foundation.Application.Ports --version 9.4.91
#r "nuget: Alvecta.Foundation.Application.Ports, 9.4.91"
#:package Alvecta.Foundation.Application.Ports@9.4.91
#addin nuget:?package=Alvecta.Foundation.Application.Ports&version=9.4.91
#tool nuget:?package=Alvecta.Foundation.Application.Ports&version=9.4.91
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]> |
IRepositorynever exposes anIQueryable. It adds, updates and deletes throughAdd*/Update*/Delete*methods, and offers a few projection-only reads for making write decisions (ExistsAsync,GetSingleAsync,GetSingleOrDefaultAsyncwith a selector).IQueryableRepositoryhands outIQueryableroots (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 (EqualTofor one key,EqualToAnyfor several) from a key selector, so every implementation of the repositories, the EF-backed ones and the in-memory fake ofAlvecta.Foundation.Application.Ports.Testingalike, 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 | Versions 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. |
-
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 | 0 | 11/25/2026 |
| 9.6.95 | 0 | 11/25/2026 |
| 9.6.94 | 81 | 11/24/2026 |
| 9.6.93 | 72 | 11/24/2026 |
| 9.5.92 | 82 | 11/24/2026 |
| 9.4.91 | 131 | 11/20/2026 |
| 9.3.90 | 146 | 11/13/2026 |
| 9.2.89 | 143 | 11/12/2026 |
| 9.1.88 | 140 | 11/11/2026 |
| 9.0.87 | 159 | 11/4/2026 |
| 9.0.86 | 146 | 11/4/2026 |
| 9.0.85 | 144 | 11/4/2026 |
| 9.0.84 | 150 | 11/4/2026 |
| 9.0.83 | 156 | 10/29/2026 |
| 9.0.82 | 155 | 10/29/2026 |
| 8.1.81 | 149 | 10/29/2026 |
| 8.0.80 | 144 | 10/28/2026 |
| 8.0.79 | 146 | 10/28/2026 |
| 8.0.78 | 144 | 10/28/2026 |
| 8.0.77 | 145 | 10/28/2026 |