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
<PackageReference Include="Bieber.Core.Primitives" Version="1.0.1" />
<PackageVersion Include="Bieber.Core.Primitives" Version="1.0.1" />
<PackageReference Include="Bieber.Core.Primitives" />
paket add Bieber.Core.Primitives --version 1.0.1
#r "nuget: Bieber.Core.Primitives, 1.0.1"
#addin nuget:?package=Bieber.Core.Primitives&version=1.0.1
#tool nuget:?package=Bieber.Core.Primitives&version=1.0.1
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 | 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. |
-
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 |