Bieber.Core.Primitives 1.0.1

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

Bieber.Core.Primitives

Bieber.Core.Primitives is a foundational library for domain-driven design (DDD) contexts. It includes abstract base classes and interfaces for entities and aggregate roots, providing a solid foundation for building robust domain models.

Features

  • Entity: Represents an abstract base class for entities with a unique identifier, providing equality comparison based on the entity's identifier.
  • AggregateRoot: Represents the base class for aggregate roots in the domain-driven design context, handling domain events.
  • IDomainEvent: Represents a domain event interface with a unique identifier for the associated aggregate.

Installation

Add the Bieber.Core.Primitives library to your project using the .NET CLI:

dotnet add package Bieber.Core.Primitives

Or add the package reference directly in your .csproj file:

<PackageReference Include="Bieber.Core.Primitives" Version="1.0.0" />

Usage

Entity

The Entity class provides a base for all entities with a unique identifier and includes methods for equality comparison.

using Bieber.Core.Primitives;

public class Customer : Entity
{
    public Customer(Guid id) : base(id) { }

    // Additional properties and methods
}

var customer1 = new Customer(Guid.NewGuid());
var customer2 = new Customer(Guid.NewGuid());

AggregateRoot

The AggregateRoot class extends Entity and includes functionality for raising and handling domain events.

using Bieber.Core.Primitives;
using System.Collections.Generic;

public class Order : AggregateRoot
{
    public Order(Guid id) : base(id) { }

    public override void ApplyEvent(IDomainEvent @event)
    {
        // Apply event logic
    }
}

public class OrderCreatedEvent : IDomainEvent
{
    public Guid AggregateId { get; }

    public OrderCreatedEvent(Guid aggregateId)
    {
        AggregateId = aggregateId;
    }
}

var order = new Order(Guid.NewGuid());
var orderCreatedEvent = new OrderCreatedEvent(order.Id);

order.Raise(orderCreatedEvent);
var events = order.GetDomainEvents(); // Contains orderCreatedEvent

License

This project is licensed under the MIT License. For more information, please see the LICENSE file.

Contributions

We welcome contributions to improve this library. Please fork the repository and submit pull requests with your changes.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 90 2/6/2025