Eiffel
  • Overview
    • About
  • Features
    • Cross cutting concerns
      • API response consistency
      • Global exception handling
      • Idempotency
      • Audit logging
    • Caching
      • Configuration
        • In-Memory
        • Redis
      • Usage
      • API
        • CacheSource
        • InMemoryCacheOptions
        • RedisCacheOptions
        • ICacheService
        • ICacheServiceFactory
    • Localization
    • Job Processing
    • Multi-Tenancy
    • Metrics & monitoring
    • Transactional outbox
      • PostgreSQL
      • MongoDB (cluster only)
    • Messaging
      • Kafka
      • Rabbit MQ
      • Azure Service Bus
    • Awaitable socket client
    • Graceful shutdown
  • Fundamentals
    • Persistence
    • Modelling
  • Principles
    • Domain-Driven Design
      • Aggregates
      • Entities
      • Value Objects
      • Domain Events
      • Factories
      • Domain Services
      • Business Identifiers
      • Shared Kernel
    • Onion Architecture
      • Application Layer
      • Domain Layer
      • Infrastructure Layer
      • Anti-Corruption Layer
    • Modular Monolith Architecture
      • Modules
      • Shared Infrastructure
    • Microservice Architecture
      • API Gateway
      • View Model Composition
      • Contracts
  • Business Aligment
    • Domain Storytelling
    • User stories
  • Implementation
    • Modular Monolith
    • Microservices
  • Testing
    • Unit Testing
    • Integration Testing
    • Contract Testing
  • Cloud Infrastructure
    • CI/CD Pipelines
    • Docker
    • Kubernates
    • Infrastructure as Code
Powered by GitBook
On this page
  1. Principles
  2. Domain-Driven Design

Entities

Entities are uniquely identifiable by a combination of one or more attributes or properties

Entities are distinct from other domain concepts such as Value Objects and Aggregates. Value Objects are immutable objects whose equality is based on their attribute values, while Aggregates are groups of related entities and value objects treated as a single unit for consistency and transactional boundaries.

Eiffel.Modelling.Abstractions NuGet package contains base Entity class. By using abstract Entity class you can define your entities.

/// <summary>
/// Base entity class
/// </summary>
/// <typeparam name="TKey">The type of database primary key</typeparam>
public abstract class EntityBase<TKey>
    where TKey : struct, IEquatable<TKey>
{
    /// <summary>
    /// Primary key
    /// </summary>
    [Key]
    public TKey Id { get; internal set; }
}

Entities are typically implemented as classes in object-oriented programming languages, and their properties and behavior reflect the essential attributes and operations of the corresponding real-world objects they represent in the domain.

Example Passenger entity with properties.

public class Passenger : EnttiyBase<long>
{
    public string Name { get; private set; }

    public string Surname { get; private set; }
}
PreviousAggregatesNextValue Objects

Last updated 1 year ago