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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Foundation.Domain.Models" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Foundation.Domain.Models" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Foundation.Domain.Models" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Foundation.Domain.Models --version 1.1.0
                    
#r "nuget: Foundation.Domain.Models, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Foundation.Domain.Models@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Foundation.Domain.Models&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Foundation.Domain.Models&version=1.1.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.1.0 476 7/22/2025
1.0.0 472 7/22/2025