DomainDrivenDesign.Core 0.2.1

dotnet add package DomainDrivenDesign.Core --version 0.2.1                
NuGet\Install-Package DomainDrivenDesign.Core -Version 0.2.1                
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="DomainDrivenDesign.Core" Version="0.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DomainDrivenDesign.Core --version 0.2.1                
#r "nuget: DomainDrivenDesign.Core, 0.2.1"                
#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.
// Install DomainDrivenDesign.Core as a Cake Addin
#addin nuget:?package=DomainDrivenDesign.Core&version=0.2.1

// Install DomainDrivenDesign.Core as a Cake Tool
#tool nuget:?package=DomainDrivenDesign.Core&version=0.2.1                

DDDCore

This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.

Articles about this Framework

How to Build a good one Value Object.

What is Domain Services? How to use it?.

Videos (English)

DDD Course - Class 00 - Overview - NetCore C#.

Videos (Portuguese)

DDD Course - Class 00 - Overview - NetCore C#.

DDD Course - Class 01 - Modeling Best Practices.

Documentation (Wiki)

Go to Documentation

Features

DomainDrivenDesign.Core

  • Entity
  • Value Object
  • Value Object Validations
  • Event
  • Raise Events (Mediator)

DomainDrivenDesign.Core.CQRS

  • Commands
  • Queries
  • MediatirCQRS to dispatch Commands and Queries

DomainDrivenDesign.Core.EventSourcing (Under development)

Nuget Packages

DomainDrivenDesign.Core

DomainDrivenDesign.Core.CQRS

Installation

You can install using nuget Package Manager

Install-Package DomainDrivenDesign.Core -Version 0.1.3
Install-Package DomainDrivenDesign.Core.CQRS -Version 0.0.1

Or using .Net Cli

dotnet add package DomainDrivenDesign.Core --version 0.1.3
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.0.1

Technologies used:

  • Railway.NetCore

Usage

You can use Value Object like this one:

Money

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Money : ValueObject<Money>
    {

        protected Money(Decimal amount, string currencyCode)
        {
            this.CheckRule(new CurrencyShouldBeSpecified(currencyCode));

            this.Amount = amount;
            this.Currency = currency;
        }

        protected Money(Decimal amount, Currency currency)
        {
            this.CheckRule(new AmountShouldBePositive(amount));

            this.Amount = amount;
            this.Currency = currency;
        }

   
        public static Money FromDecimal(
            decimal amount,
            string currency)
            => new Money(amount, currency);


        public decimal ToDecimal()
         => Amount;

        protected override IEnumerable<object> GetEqualityComponents()
        {
            yield return Amount;
            yield return Currency;
        }

        public Decimal Amount { get; }

        public String Currency { get; }
    }

CurrencyShouldBeSpecified.cs

    using DomainDrivenDesign.Core.Interfaces;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class CurrencyShouldBeSpecified : IValidationRule
    {
        private readonly string _value;

        internal CurrencyShouldBeSpecified(string value)
        {
            this._value = value;
        }

        public string Message => "Currency code must be specified";

        public bool IsBroken()
        {
            return (string.IsNullOrEmpty(_value));
        }
    }

Also, you can use Entity Object.

Payment.cs Entity Sample

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;


    public class Payment : Entity
    {

        public Card Card { get; protected set; }

        public Money Amount { get; protected set; }

        public string BeneficiaryAlias { get; protected set; }


        public DateTime CreatedOn { get; protected set; }


        public static Result<Payment> CreateNewCardPayment(Card card, Money amount, string beneficiaryAlias)
        {
            return Result.Success(new Payment(card, amount, beneficiaryAlias));
        }


        private Payment(Card card, Money amount, string beneficiaryAlias) : base()
        {
            this.Card = card;
            this.Amount = amount;
            this.BeneficiaryAlias = beneficiaryAlias;
            this.CreatedOn = DateTime.Now;
        }
    }

Soon Mediator, Command, Query and Handlers samples. If you wish you can see this samples on Sample Project.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DomainDrivenDesign.Core:

Package Downloads
DomainDrivenDesign.Core.CQRS

This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 683 8/1/2020
0.2.0 646 7/27/2020
0.1.3 474 7/23/2020
0.0.2 509 7/23/2020
0.0.1 431 7/23/2020

Add Event class
Add Event Handler
Add Mediator to Raise Event