Compendium.Core
1.0.0
See the version list below for details.
dotnet add package Compendium.Core --version 1.0.0
NuGet\Install-Package Compendium.Core -Version 1.0.0
<PackageReference Include="Compendium.Core" Version="1.0.0" />
<PackageVersion Include="Compendium.Core" Version="1.0.0" />
<PackageReference Include="Compendium.Core" />
paket add Compendium.Core --version 1.0.0
#r "nuget: Compendium.Core, 1.0.0"
#:package Compendium.Core@1.0.0
#addin nuget:?package=Compendium.Core&version=1.0.0
#tool nuget:?package=Compendium.Core&version=1.0.0
Compendium.Core
The core domain primitives and patterns for the Compendium Framework. This library provides the fundamental building blocks for implementing Domain-Driven Design (DDD) patterns in .NET applications.
Features
Domain Primitives
- Entity<TId>: Base class for all domain entities with identity, timestamps, and business rule validation
- AggregateRoot<TId>: Base class for aggregate roots with domain event management and optimistic concurrency
- ValueObject: Base class for value objects with structural equality
Domain Events
- IDomainEvent: Interface for domain events within bounded contexts
- DomainEventBase: Base implementation for domain events
- IIntegrationEvent: Interface for integration events across bounded contexts
Business Rules
- IBusinessRule: Interface for encapsulating business rules and invariants
- BusinessRuleValidationException: Exception thrown when business rules are violated
Specifications
- ISpecification<T>: Interface for the Specification pattern with query composition
- Specification<T>: Base implementation with logical operators (And, Or, Not)
Result Pattern
- Result: Represents operation results without exceptions
- Result<T>: Generic result with value
- Error: Structured error information with types and metadata
- ResultExtensions: Functional programming extensions (Map, Bind, Match)
Usage Examples
Entity with Business Rules
public class User : Entity<UserId>
{
public User(UserId id, string email, string name) : base(id)
{
CheckRule(new ValidEmailRule(email));
CheckRule(new NonEmptyNameRule(name));
Email = email;
Name = name;
}
public string Email { get; private set; }
public string Name { get; private set; }
}
Aggregate Root with Domain Events
public class Order : AggregateRoot<OrderId>
{
public void PlaceOrder()
{
CheckRule(new OrderMustHaveItemsRule(Items));
Status = OrderStatus.Placed;
AddDomainEvent(new OrderPlacedEvent(Id, CustomerId, TotalAmount));
IncrementVersion();
}
}
Value Object
public class Money : ValueObject
{
public Money(decimal amount, string currency)
{
Amount = amount;
Currency = currency;
}
public decimal Amount { get; }
public string Currency { get; }
protected override IEnumerable<object?> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
}
Result Pattern
public Result<User> CreateUser(string email, string name)
{
if (string.IsNullOrWhiteSpace(email))
return Error.Validation("User.Email.Empty", "Email cannot be empty");
if (string.IsNullOrWhiteSpace(name))
return Error.Validation("User.Name.Empty", "Name cannot be empty");
var user = new User(UserId.New(), email, name);
return Result.Success(user);
}
// Usage with functional composition
var result = CreateUser(email, name)
.Map(user => new UserDto(user.Id, user.Email, user.Name))
.Tap(dto => logger.LogInformation("User created: {UserId}", dto.Id))
.Match(
onSuccess: dto => Ok(dto),
onFailure: error => BadRequest(error.Message)
);
Specifications
public class ActiveUsersSpecification : Specification<User>
{
public ActiveUsersSpecification() : base(user => user.IsActive)
{
ApplyOrderBy(user => user.Name);
}
}
// Composition
var spec = new ActiveUsersSpecification()
.And(new UsersByRoleSpecification("Admin"))
.Or(new UsersByRoleSpecification("Manager"));
Design Principles
- No External Dependencies: Core library only uses .NET BCL
- Immutability by Default: Value objects and events are immutable
- Thread Safety: All implementations are thread-safe
- Functional Patterns: Result pattern eliminates exceptions for control flow
- Rich Domain Models: Entities encapsulate behavior and enforce invariants
- Event-Driven Architecture: Support for domain and integration events
License
Copyright (c) 2026 Sassy Solutions. Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- No dependencies.
NuGet packages (49)
Showing the top 5 NuGet packages that depend on Compendium.Core:
| Package | Downloads |
|---|---|
|
Compendium.Abstractions
Core abstractions and interfaces for Compendium Framework: CQRS (ICommandHandler, IQueryHandler), Event Sourcing (IEventStore, IProjection), Idempotency, Sagas. |
|
|
Compendium.Abstractions.AI
AI/LLM abstractions for Compendium Framework: IAIProvider, IPromptRegistry, IContextBuilder. Provider-agnostic interfaces for AI completions, embeddings, and prompt management. |
|
|
Compendium.Multitenancy
Multi-tenancy for Compendium Framework: Tenant resolution (header/subdomain/path), isolation strategies (database/schema/row-level), tenant context management for SaaS applications. |
|
|
Compendium.Infrastructure
Infrastructure layer for Compendium Framework: Event Store abstraction, Projections, Sagas, Resilience (retry/circuit breaker), Observability (Serilog/OpenTelemetry), Security, Encryption. |
|
|
Compendium.Application
Application layer for Compendium Framework: CQRS dispatchers, Idempotency service, Saga orchestration, Pipeline behaviors. Build event-driven applications with clean architecture. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.3 | 435 | 5/21/2026 |
| 1.0.2 | 503 | 5/18/2026 |
| 1.0.1 | 1,348 | 5/16/2026 |
| 1.0.0 | 804 | 5/14/2026 |
| 1.0.0-preview.9 | 597 | 5/14/2026 |
| 1.0.0-preview.8 | 2,033 | 5/2/2026 |
| 1.0.0-preview.7 | 93 | 5/2/2026 |
| 1.0.0-preview.6 | 131 | 5/2/2026 |
| 1.0.0-preview.5 | 114 | 4/30/2026 |
| 1.0.0-preview.4 | 187 | 4/26/2026 |
| 1.0.0-preview.3 | 91 | 4/26/2026 |
| 1.0.0-preview.2 | 81 | 4/25/2026 |
| 1.0.0-preview.1 | 174 | 4/24/2026 |