The LogicBuilder.Domain project provides foundational classes for building domain models in a layered architecture pattern.
This project contains the BaseModel abstract class, which serves as the base class for all domain model entities in the application layer. Domain models represent business entities and logic, distinct from data persistence concerns.
An abstract base class implements the IBaseData interface which all domain model entities should implement.
Features:
- EntityState Property: Tracks the state of the entity (
Unchanged,Added,Modified,Deleted) using theEntityStateTypeenum fromLogicBuilder.Data - Change Tracking: Enables generic CRUD operations in
LogicBuilder.EntityFrameworkCore.SqlServerwithout coupling domain models directly to Entity Framework
The BaseModel class is central to the repository pattern implementation:
- ModelRepositoryBase: Generic repository operations require models to implement
IBaseModel(constraint:where TModel : IBaseModel) - State Management: The
EntityStateproperty is mapped from domain models to Entity Framework'sEntityStateduring save operations - Graph Operations: Enables tracking of complex object graphs for insert, update, and delete operations through the
SaveGraphAsyncmethods
This follows a layered architecture approach:
- LogicBuilder.Domain (Domain Layer): Business entities implementing
IBaseModel - LogicBuilder.Data (Data Layer): Database entities implementing
IBaseData - AutoMapper: Translates between domain models and data entities
- LogicBuilder.EntityFrameworkCore.SqlServer: Provides generic repository pattern supporting both layers
By inheriting from BaseModel, your domain entities gain state tracking capabilities while remaining independent of Entity Framework infrastructure concerns.