Skip to content

Repository files navigation

BeyondNet.Ddd

A Domain-Driven Design (DDD) library for .NET

English | Español

NuGetBuild


Welcome to BeyondNet.Ddd! A library for implementing Domain-Driven Design patterns in .NET with clean, maintainable code.

Installation

NuGet Packages

# Core DDD library
dotnet add package BeyondNetCode.Shell.Ddd
# Value Objects
dotnet add package BeyondNetCode.Shell.Ddd.ValueObjects
# AutoMapper integration
dotnet add package BeyondNetCode.Shell.Ddd.AutoMapper

Packages Overview

PackageDescriptionNuGet
BeyondNetCode.Shell.DddCore DDD abstractions (Entity, AggregateRoot, DomainEvents, Rules)link
BeyondNetCode.Shell.Ddd.ValueObjectsPre-built value objects (IdValueObject, AuditValueObject, Validators)link
BeyondNetCode.Shell.Ddd.AutoMapperAutoMapper integration for DDD entitieslink

Features

  • Entity Base Class: Full-featured entity implementation with tracking, validation, and business rules
  • Aggregate Root: Specialized entity for aggregate roots with domain events support
  • Value Objects: Immutable value objects with built-in validation
  • Business Rules: Rule engine with BrokenRulesManager for domain validation
  • Property Change Tracking: INotifyPropertyChanged implementation with change tracking
  • AutoMapper Integration: Seamless mapping between DTOs and domain entities
  • MediatR Integration: Built-in support for domain events via MediatR

Quick Start

Define an Entity

publicclassSampleName:ValueObject<SampleName>{publicstringValue{get;}publicSampleName(stringvalue){if(string.IsNullOrWhiteSpace(value))thrownewArgumentNullException(nameof(value));Value=value;}protectedoverrideIEnumerable<object>GetEqualityComponents(){yieldreturnValue;}}publicclassSampleEntityProps:IProps{publicSampleNameName{get;set;}}publicclassSampleEntity:Entity<SampleEntity,SampleEntityProps>{publicSampleEntity(SampleEntityPropsprops):base(props){}publicstaticSampleEntityCreate(stringname){varprops=newSampleEntityProps{Name=newSampleName(name)};returnnewSampleEntity(props);}publicoverridevoidAddValidators(){ValidatorRules.Add(newSampleNameValidator());}}

Define an Aggregate Root with Domain Events

publicclassSampleCreatedDomainEvent:DomainEvent{publicGuidEntityId{get;}publicstringName{get;}publicSampleCreatedDomainEvent(GuidentityId,stringname){EntityId=entityId;Name=name;}}publicclassSampleAggregateRootProps:IProps{publicSampleNameName{get;set;}}publicclassSampleAggregateRoot:AggregateRoot<SampleAggregateRoot,SampleAggregateRootProps>{publicSampleAggregateRoot(SampleAggregateRootPropsprops):base(props){}publicstaticSampleAggregateRootCreate(stringname){varprops=newSampleAggregateRootProps{Name=newSampleName(name)};varentity=newSampleAggregateRoot(props);entity.DomainEvents.Add(newSampleCreatedDomainEvent(entity.Id.Value,name));returnentity;}}

Use with AutoMapper

// Configure AutoMappervarconfig=newMapperConfiguration(cfg =>{cfg.AddProfile<ParentRootProfile>();});varmapper=newMapper(config);// Map DTO to Entityvardto=newSampleEntityDto{Id="1",Name="test"};varprops=mapper.Map<SampleEntityProps>(dto);varentity=newSampleEntity(props);

Documentation

For detailed documentation, see the language-specific README files:

Migration from Ums.Shell.Ddd

If you were using Ums.Shell.Ddd, update your NuGet references:

# Before (Ums.Shell.Ddd)
dotnet add package Ums.Shell.Ddd
# After (BeyondNetCode.Shell.Ddd)
dotnet add package BeyondNetCode.Shell.Ddd

Update namespaces in your code:

// BeforeusingUms.Shell.Ddd;// AfterusingBeyondNetCode.Shell.Ddd;

Contributing

See CONTRIBUTING.md for GitFlow workflow, commit conventions, and coding standards.

Versioning

See VERSIONING.md for SemVer strategy and release process.

License

Licensed under the MIT License. See LICENSE for details.

Acknowledgments

See DISCLAIMER.md for original code authorship attribution.

About

Domain-Driven Design library for .NET with entities, aggregate roots, value objects, domain events, business rules, and AutoMapper support.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages