Foundation.Domain.Models
1.1.0
dotnet add package Foundation.Domain.Models --version 1.1.0
NuGet\Install-Package Foundation.Domain.Models -Version 1.1.0
<PackageReference Include="Foundation.Domain.Models" Version="1.1.0" />
<PackageVersion Include="Foundation.Domain.Models" Version="1.1.0" />
<PackageReference Include="Foundation.Domain.Models" />
paket add Foundation.Domain.Models --version 1.1.0
#r "nuget: Foundation.Domain.Models, 1.1.0"
#:package Foundation.Domain.Models@1.1.0
#addin nuget:?package=Foundation.Domain.Models&version=1.1.0
#tool nuget:?package=Foundation.Domain.Models&version=1.1.0
Foundation.Domain.Models
Core domain models and base entities for the Foundation framework, implementing Domain-Driven Design patterns.
📦 Package Contents
This package provides the foundational building blocks for domain-driven applications:
- Base Entities:
BaseEntity
with audit fields (Id, CreatedAt, UpdatedAt, DeletedAt) - Domain Events: Event interfaces and base implementations for event-driven architecture
- Value Objects: Common value objects (Email, Money, Address, etc.)
- Specifications: Specification pattern implementation for complex queries
- Enumerations: Base enumeration class for type-safe enums
- Exceptions: Domain-specific exceptions
🚀 Installation
dotnet add package Foundation.Domain.Models
📖 Usage
Base Entity
All domain entities should inherit from BaseEntity
:
public class Product : BaseEntity
{
public string Name { get; private set; }
public decimal Price { get; private set; }
public Product(string name, decimal price)
{
Name = name;
Price = price;
RaiseDomainEvent(new ProductCreatedEvent(Id, name, price));
}
}
Domain Events
Implement domain events for decoupled communication:
public record ProductCreatedEvent(Guid ProductId, string Name, decimal Price) : IDomainEvent
{
public DateTime OccurredAt { get; } = DateTime.UtcNow;
}
Value Objects
Use value objects for domain concepts without identity:
public class Email : ValueObject
{
public string Value { get; }
public Email(string value)
{
if (!IsValid(value))
throw new DomainException("Invalid email format");
Value = value.ToLowerInvariant();
}
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}
Specifications
Build complex queries with the specification pattern:
public class ActiveProductsSpecification : Specification<Product>
{
public override Expression<Func<Product, bool>> ToExpression()
{
return product => product.DeletedAt == null && product.IsActive;
}
}
// Usage
var activeProducts = await repository.GetAsync(new ActiveProductsSpecification());
🏗️ Architecture
This package follows Clean Architecture principles:
- No external dependencies: Pure domain logic only
- Immutability: Value objects are immutable by design
- Encapsulation: Entities protect their invariants
- Event-driven: Domain events for loose coupling
📋 Requirements
- .NET 8.0 or higher
- C# 12.0 or higher
🤝 Contributing
This package is part of the Foundation framework. See the main repository for contribution guidelines.
📄 License
MIT License - see LICENSE file for details.
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
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Foundation.Domain.Models:
Package | Downloads |
---|---|
Foundation.Application.Contracts
Application contracts including DTOs, command/query interfaces, and service contracts for Foundation framework. Provides clean separation between application logic and implementation details. |
|
Foundation.Infrastructure.Common
Common infrastructure implementations for Foundation microservices including caching, logging, middleware, and resilience patterns. |
GitHub repositories
This package is not used by any popular GitHub repositories.