Domain
Overview
Core.Domain encapsulates basic DDD classes and interfaces for easier and standardize implementation of your service Core or Supplementary Domain.
Install
- ASOL.Core.Domain - Domain entity base implementations.
- ASOL.Core.Domain.Contracts - DTO models for domain entity.
Changelog
ASOL.Core.Domain
- 0.0.1.32018-dev
- 0.0.1.30653-dev
- 0.0.1.25417-dev
ASOL.Core.Domain.Contracts
- 0.0.1.32018-dev
- 0.0.1.30653-dev
- 0.0.1.25417-dev
Upgrade nugets
Version 0.0.1.18780-dev was added BaseEntity and BaseEntityModel properties: CreatedOn and CreatedBy. If you have same properties on your entities based on BaseEntity or BaseEntityOrganization you must resolve conflict. First part will be remove your own properties and use properties from ancestor. If you use EfCore as persistence layer you must create database migration.
Domain entity based on BaseEntity with organization identification
/// <summary>
/// Root entity for this domain.
/// </summary>
public class Book : BaseEntityOrganization<string>
{
/// <summary>
/// Constructor for serialize/deserialize. Don't use it directly.
/// </summary>
public Book()
{
Name = default!;
}
/// <summary>
/// Initialize new <see cref="Book"/> entity instance with mandatory parameters.
/// </summary>
/// <param name="id">Unique identifier for this entity instance. It can be Guid.NewGuid() for example.</param>
/// <param name="user">Current principal.</param>
/// <param name="name">Value of <see cref="Name"/> property.</param>
/// <param name="organizationId">Current organization owner of this instance.</param>
public Book(string id, ClaimsPrincipal user, string name, string? organizationId)
: base(id, user, organizationId)
{
Name = name;
}
/// <summary>
/// Example property as user defined Name for entity.
/// </summary>
[Required]
public string Name { get; set; }
}
Domain entity based on ValueObject
public class PersonCacheItem : ValueObject
{
public PersonCacheItem(string code, string name)
{
Code = code;
Name = name;
}
public string Code { get; set; }
public string Name { get; }
protected override IEnumerable<object> GetAtomicValues()
{
yield return Code;
yield return Name;
}
}