Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence
1.0.1
dotnet add package Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence --version 1.0.1
NuGet\Install-Package Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence -Version 1.0.1
<PackageReference Include="Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence" Version="1.0.1" />
<PackageVersion Include="Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence" Version="1.0.1" />
<PackageReference Include="Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence" />
paket add Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence --version 1.0.1
#r "nuget: Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence, 1.0.1"
#:package Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence@1.0.1
#addin nuget:?package=Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence&version=1.0.1
#tool nuget:?package=Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence&version=1.0.1
CleanArchitecture.Core.Infrastructure.Persistence
Core infrastructure persistence implementations for Entity Framework Core including unit of work, transactions, criteria extensions, domain event collection, and audit interceptors.
Purpose
This package provides base Entity Framework Core implementations of persistence abstractions including unit of work pattern, transaction management, criteria query extensions, domain event collection, and automatic audit field management. It works with CleanArchitecture.Core.Application to provide a complete persistence foundation for Clean Architecture applications.
Installation
dotnet add package Mohd2sh.CleanArchitecture.Core.Infrastructure.Persistence
Usage
Register Unit of Work
services.AddScoped<IUnitOfWork>(sp =>
new EfUnitOfWork(sp.GetRequiredService<ApplicationDbContext>()));
Using EfCriteria Extensions
public class ProductRepository
{
private readonly DbContext _db;
public async Task<PaginatedList<Product>> GetProductsAsync(
int pageNumber,
int pageSize,
string? searchTerm)
{
var criteria = Criteria<Product>.New()
.Where(p => searchTerm == null || p.Name.Contains(searchTerm))
.OrderByAsc(p => p.Name)
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.Build();
var (query, totalCount) = await _db.Set<Product>()
.ApplyWithCountAsync(criteria);
var items = await query.ToListAsync();
return new PaginatedList<Product>(items, totalCount, pageNumber, pageSize);
}
}
Domain Event Collection
// After SaveChangesAsync, collect domain events
var domainEvents = _dbContext.CollectAndClear();
// Domain events are automatically cleared from aggregates
// Dispatch events through your event dispatcher
foreach (var domainEvent in domainEvents)
{
await _domainEventDispatcher.PublishAsync(domainEvent);
}
Auditable Entity Interceptor
// Register the interceptor in your DbContext configuration
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.AddInterceptors(new AuditableEntityInterceptor(
_dateTimeProvider,
() => _currentUserService.GetCurrentUserId()));
}
// Entities implementing IAuditableEntity will automatically have
// CreatedAt, CreatedBy, LastModifiedAt, LastModifiedBy set
Dependencies
Requires CleanArchitecture.Core.Application and Microsoft.EntityFrameworkCore.
Repository
GitHub: https://github.com/mohd2sh/CleanArchitecture-DDD-CQRS
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Mohd2sh.CleanArchitecture.Core.Application (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 300 | 11/30/2025 |