Tolitech.Domain 1.0.0-preview.8

This is a prerelease version of Tolitech.Domain.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Tolitech.Domain --version 1.0.0-preview.8
                    
NuGet\Install-Package Tolitech.Domain -Version 1.0.0-preview.8
                    
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="Tolitech.Domain" Version="1.0.0-preview.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Domain" Version="1.0.0-preview.8" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Domain" />
                    
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 Tolitech.Domain --version 1.0.0-preview.8
                    
#r "nuget: Tolitech.Domain, 1.0.0-preview.8"
                    
#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 Tolitech.Domain@1.0.0-preview.8
                    
#: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=Tolitech.Domain&version=1.0.0-preview.8&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Domain&version=1.0.0-preview.8&prerelease
                    
Install as a Cake Tool

Tolitech.Domain

Overview

Tolitech.Domain provides the core abstractions and primitives for building robust domain layers in .NET applications, following Clean Architecture principles. It includes base classes and interfaces for Entities, Aggregates, Domain Events, Smart Enums, and Repositories.

Features

  • Entities & Aggregates: Abstract base classes and interfaces for domain modeling.
  • Domain Events: Interfaces for event-driven domain logic.
  • SmartEnum: Type-safe, extensible enums with custom logic.
  • Repositories: Generic repository interfaces for persistence abstraction.
  • Validation: Entity validation via the Result pattern.

Installation

Add a reference to the Tolitech.Domain project or install via NuGet:

# .NET CLI
 dotnet add package Tolitech.Domain

Usage

Entity & Aggregate Example

public class ProductId : IEntityId<Guid>
{
    public Guid Value { get; init; }
    public ProductId(Guid value) => Value = value;
}

public class Product : Entity<ProductId>
{
    public string Name { get; set; }
    public Product(ProductId id, string name) : base(id) => Name = name;
}

public class Order : Aggregate<Guid>
{
    public List<Product> Products { get; set; } = new();
    public Order(Guid id) : base(id) { }
}

SmartEnum Example

public class CreditCard : SmartEnum<CreditCard>
{
    public static readonly CreditCard Standard = new(1, "Standard", 0.0);
    public static readonly CreditCard Premium = new(2, "Premium", 0.05);
    public static readonly CreditCard Platinum = new(3, "Platinum", 0.10);
    public double Discount { get; }
    private CreditCard(int value, string name, double discount) : base(value, name) => Discount = discount;
}

// Usage
var platinum = CreditCard.FromName("Platinum");

Domain Event Example

public class ProductCreatedEvent : IDomainEvent
{
    public ProductId ProductId { get; }
    public ProductCreatedEvent(ProductId productId) => ProductId = productId;
}

Repository Interface Example

public interface IProductRepository : IRepository<Product> { }

Validation Example

var product = new Product(new ProductId(Guid.NewGuid()), "Laptop");
var result = Tolitech.Results.Result.OK();
bool isValid = product.IsValid(result);

Notes

  • Designed for extensibility and integration with other Tolitech libraries.
  • Follows Clean Architecture and DDD best practices.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Tolitech.Domain:

Package Downloads
Tolitech.Infrastructure.Persistence.EntityFrameworkCore

The Tolitech.Infrastructure.Persistence.EntityFrameworkCore repository provides a foundational implementation for the Repository pattern, Unit of Work, and Specification Query Builder using Entity Framework Core. Simplify database interaction, promote code organization, and maintenance using these widely recognized patterns.

Tolitech.Domain.Specifications

The Domain.Specifications repository provides a foundational implementation for the Specification pattern within the Clean Architecture context.

Tolitech.Domain.Results.Guards

This library contains specific Guards to validate domain artifacts such as Entities, Aggregates, Value Objects, and EntityId.

Tolitech.Application.Mediator

The Application repository simplifies the separation of commands and queries, promoting a clean and maintainable architecture.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.9 149 8/4/2025
1.0.0-preview.8 363 7/21/2025
1.0.0-preview.7 129 7/7/2025
1.0.0-preview.6 114 7/7/2025
1.0.0-preview.5 125 7/3/2025
1.0.0-preview.4 124 7/3/2025
1.0.0-preview.3 110 1/27/2025
1.0.0-preview.2 86 1/6/2025
1.0.0-preview.1 109 12/8/2024