Moclawr.Domain 2.1.0

dotnet add package Moclawr.Domain --version 2.1.0
                    
NuGet\Install-Package Moclawr.Domain -Version 2.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="Moclawr.Domain" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moclawr.Domain" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Moclawr.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 Moclawr.Domain --version 2.1.0
                    
#r "nuget: Moclawr.Domain, 2.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.
#addin nuget:?package=Moclawr.Domain&version=2.1.0
                    
Install Moclawr.Domain as a Cake Addin
#tool nuget:?package=Moclawr.Domain&version=2.1.0
                    
Install Moclawr.Domain as a Cake Tool

Moclawr.Domain

NuGet

Overview

Moclawr.Domain provides essential domain modeling components for building robust business logic layers in .NET applications. It includes base entity classes, builder interfaces, and domain event infrastructure to support Domain-Driven Design (DDD) principles.

Features

  • Base Entity Types: Ready-to-use base classes for domain entities
  • Tracking Entities: Support for audit fields (created/modified timestamps and users)
  • Builder Interfaces: Fluent interfaces for constructing entities and queries
  • Domain Events: Infrastructure for implementing domain events
  • Specifications: Pattern implementation for complex business rules

Installation

dotnet add package Moclawr.Domain

Usage Examples

Base Entities

// Create a domain entity with audit tracking
public class Customer : TrackEntity<Guid>
{
    public string Name { get; private set; }
    public string Email { get; private set; }
    
    public Customer(string name, string email)
    {
        Name = name;
        Email = email;
    }
    
    public void UpdateContact(string email)
    {
        Email = email;
        UpdatedAt = DateTime.UtcNow;
    }
}

Builder Interfaces

// Implement a fluent builder for an entity
public class CustomerBuilder : IEntityBuilder<Customer>
{
    private string _name = string.Empty;
    private string _email = string.Empty;

    public CustomerBuilder WithName(string name)
    {
        _name = name;
        return this;
    }
    
    public CustomerBuilder WithEmail(string email)
    {
        _email = email;
        return this;
    }
    
    public Customer Build()
    {
        return new Customer(_name, _email);
    }
}

Query Building

// Use the fluent query builder
var customers = await repository.GetAllAsync(builder => 
    builder
        .Where(c => c.IsActive)
        .OrderBy(c => c.Name)
        .Include(c => c.Orders)
);

Integration with Other Moclawr Packages

Moclawr.Domain is designed to work with:

  • Moclawr.Core: Leverages extension methods and utilities for enhanced functionality
  • Moclawr.Shared: Builds on base entity interfaces and standardized response models
  • Moclawr.EfCore and Moclawr.MongoDb: Provides base classes for data models and repository patterns
  • Moclawr.MinimalAPI: Perfect for CQRS handlers and domain-driven endpoint design
  • Moclawr.Host: Integrates with domain event handling and business logic validation

Requirements

  • .NET 9.0 or higher

License

This project is licensed under the MIT License - see the LICENSE file for details.

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 (2)

Showing the top 2 NuGet packages that depend on Moclawr.Domain:

Package Downloads
Moclawr.MongoDb

MongoDB integration for the moclaw project. Provides context and repositories for MongoDB data access.

Moclawr.EfCore

EF Core integration for the moclaw project. Provides base context, repositories, and builders for relational data access.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 251 5/28/2025
2.0.0 188 5/24/2025
1.0.3 66 5/24/2025
1.0.2 141 5/22/2025
1.0.1 146 5/21/2025
1.0.0 221 5/15/2025

Added improved XML documentation and bug fixes.