AkbarAmd.SharedKernel.Domain
1.0.18
See the version list below for details.
dotnet add package AkbarAmd.SharedKernel.Domain --version 1.0.18
NuGet\Install-Package AkbarAmd.SharedKernel.Domain -Version 1.0.18
<PackageReference Include="AkbarAmd.SharedKernel.Domain" Version="1.0.18" />
<PackageVersion Include="AkbarAmd.SharedKernel.Domain" Version="1.0.18" />
<PackageReference Include="AkbarAmd.SharedKernel.Domain" />
paket add AkbarAmd.SharedKernel.Domain --version 1.0.18
#r "nuget: AkbarAmd.SharedKernel.Domain, 1.0.18"
#:package AkbarAmd.SharedKernel.Domain@1.0.18
#addin nuget:?package=AkbarAmd.SharedKernel.Domain&version=1.0.18
#tool nuget:?package=AkbarAmd.SharedKernel.Domain&version=1.0.18
AkbarAmd.SharedKernel.Domain
Clean Architecture Domain Layer - Core Domain Models, Entities, Value Objects, and Domain Events
Overview
The Domain layer is the core of Clean Architecture, containing business logic, domain models, and domain rules. This package provides foundational building blocks for implementing Domain-Driven Design (DDD) patterns in .NET applications.
Purpose
This layer defines:
- Business entities and their relationships
- Domain rules and business invariants
- Value objects for domain concepts
- Domain events for domain state changes
- Specifications for complex business queries
- Aggregate roots that enforce consistency boundaries
Key Components
Entities & Aggregate Roots
Entity<TKey>: Base entity class with identity managementAggregateRoot<TKey>: Aggregate root with domain events and concurrency controlCreatableAggregateRoot<TKey>: Aggregate root with creation trackingModifiableAggregateRoot<TKey>: Aggregate root with modification trackingSoftDeletableAggregateRoot<TKey>: Aggregate root with soft delete supportFullAggregateRoot<TKey>: Complete aggregate root with all tracking features
Value Objects
ValueObject: Immutable value object base classEnumeration: Smart enumeration pattern for domain constants
Domain Events
IDomainEvent: Interface for domain events- Built-in domain event management within aggregate roots
- Thread-safe domain event collection
Specifications
ISpecification<T>: Specification pattern interfaceCriteriaBuilder<T>: Fluent API for building query criteriaCriteriaChain<T>: Chain multiple criteria together
Outbox Pattern
OutboxMessage: Aggregate root for reliable message processing- Status tracking and retry mechanism
- Domain events for state changes
Repositories
IRepository<T, TKey>: Generic repository interfaceIReadOnlyRepository<T, TKey>: Read-only repository interface
Features
- Domain-Driven Design: Full DDD support with aggregate roots and entities
- Event Sourcing Ready: Built-in domain event management
- Audit Trail: Comprehensive audit capabilities (creation, modification, deletion)
- Concurrency Control: Optimistic concurrency with version tracking
- Thread Safety: Thread-safe domain event operations
- Specification Pattern: Complex query building with business rules
- Outbox Pattern: Reliable message processing for distributed systems
Installation
dotnet add package AkbarAmd.SharedKernel.Domain
Usage Examples
Creating an Aggregate Root
public class User : AggregateRoot<Guid>
{
public string Email { get; private set; }
public string Name { get; private set; }
private User() { } // For EF Core
public User(string email, string name)
{
Id = Guid.NewGuid();
Email = email;
Name = name;
// Raise domain event
RaiseDomainEvent(new UserCreatedEvent(Id, Email));
}
public void UpdateName(string newName)
{
if (string.IsNullOrWhiteSpace(newName))
throw new DomainBusinessRuleValidationException("Name cannot be empty");
Name = newName;
RaiseDomainEvent(new UserNameChangedEvent(Id, newName));
}
}
Using Value Objects
public class Email : ValueObject
{
public string Value { get; }
public Email(string value)
{
if (string.IsNullOrWhiteSpace(value) || !value.Contains("@"))
throw new ArgumentException("Invalid email");
Value = value;
}
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}
Using Specifications
var activeUsersSpec = new CriteriaBuilder<User>()
.Where(u => u.IsActive)
.OrderBy(u => u.CreatedAt)
.Take(10)
.Build();
var users = await repository.GetAsync(activeUsersSpec);
Dependencies
- .NET 8.0 or later
- No external dependencies (pure domain layer)
Architecture Principles
This layer follows Clean Architecture principles:
- No dependencies on other layers
- Pure business logic without infrastructure concerns
- Framework-agnostic domain models
- Testable in isolation
License
MIT License - see LICENSE file for details.
Author
Akbar Ahmadi Saray - GitHub
| 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. |
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AkbarAmd.SharedKernel.Domain:
| Package | Downloads |
|---|---|
|
AkbarAmd.SharedKernel.Application
Clean Architecture Application Layer - CQRS, MediatR, Validation, and Application Services |
|
|
AkbarAmd.SharedKernel.Infrastructure.EntityFrameworkCore
Clean Architecture Infrastructure Layer - EF Core Integration, Repository Implementations, and Data Access |
|
|
AkbarAmd.SharedKernel.Infrastructure
Clean Architecture Infrastructure Layer - EF Core Integration, Repository Implementations, and Data Access |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.27 | 109 | 2/1/2026 |
| 1.0.26 | 727 | 12/3/2025 |
| 1.0.25 | 716 | 12/2/2025 |
| 1.0.24 | 720 | 12/2/2025 |
| 1.0.23 | 722 | 12/2/2025 |
| 1.0.21 | 685 | 12/2/2025 |
| 1.0.20 | 616 | 12/1/2025 |
| 1.0.19 | 300 | 11/30/2025 |
| 1.0.18 | 167 | 11/29/2025 |
| 1.0.17 | 336 | 11/11/2025 |
| 1.0.16 | 330 | 11/11/2025 |
| 1.0.15 | 215 | 10/20/2025 |
| 1.0.14 | 209 | 10/20/2025 |
| 1.0.13 | 369 | 9/16/2025 |
| 1.0.11 | 232 | 8/18/2025 |
| 1.0.10 | 158 | 8/3/2025 |
| 1.0.9 | 175 | 8/3/2025 |
| 1.0.8 | 157 | 8/3/2025 |
Version 1.0.18:
- Removed Version property and IncrementVersion() method from IAggregateRoot<TId> interface and AggregateRoot<TKey> class
- Renamed LastModifiedAt to ModifiedAt and LastModifiedBy to ModifiedBy in IModifiableAudit interface
- Updated all aggregate root implementations and DTOs to use ModifiedAt/ModifiedBy naming
- Updated Entity Framework Core configurations to reflect property name changes
- Breaking change: Aggregate roots no longer support version-based optimistic concurrency control (RowVersion still available via IConcurrentAudit)
- Breaking change: IModifiableAudit properties renamed from LastModifiedAt/LastModifiedBy to ModifiedAt/ModifiedBy