Moclawr.Domain
2.1.0
dotnet add package Moclawr.Domain --version 2.1.0
NuGet\Install-Package Moclawr.Domain -Version 2.1.0
<PackageReference Include="Moclawr.Domain" Version="2.1.0" />
<PackageVersion Include="Moclawr.Domain" Version="2.1.0" />
<PackageReference Include="Moclawr.Domain" />
paket add Moclawr.Domain --version 2.1.0
#r "nuget: Moclawr.Domain, 2.1.0"
#addin nuget:?package=Moclawr.Domain&version=2.1.0
#tool nuget:?package=Moclawr.Domain&version=2.1.0
Moclawr.Domain
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 | 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
- Mapster (>= 7.4.0)
- Moclawr.Shared (>= 2.0.1)
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.
Added improved XML documentation and bug fixes.