Skip to main content

Employee CQRS

Summary​

Employee Service implements CQRS with local marker interfaces and generic handler interfaces. Handlers are resolved directly through dependency injection; no MediatR package, mediator object, reflection dispatcher, or central command bus is present.

Audience​

  • Backend developers
  • QA engineers and solution architects

Purpose​

Explain how request handlers reach write and read use cases and where the current CQRS implementation remains transitional.

Command flow​

Query flow​

Implementation details​

  • Commands implement ICommand<TResult> and queries implement IQuery<TResult>.
  • Scoped handlers implement ICommandHandler or IQueryHandler and expose HandleAsync.
  • Result<T> distinguishes success, validation, not-found, and conflict outcomes.
  • Command handlers own validation invocation, mutation, audit, and commit.
  • Query handlers use no-tracking/projection-oriented reads and do not commit.
  • Cancellation tokens flow through handlers and persistence operations.

Transitional duplication​

Typed CQRS handlers coexist with EmployeeCommands and EmployeeQueries application services used by other presentation mappings. No automatic pipeline coordinates both styles. Consolidation and a single dispatcher Require confirmation.

Source References​

  • microservices/src/employee-service/Application/Common/Cqrs.cs
  • microservices/src/employee-service/Application/Commands/EmployeeApplicationCommands.cs
  • microservices/src/employee-service/Application/Queries/EmployeeApplicationQueries.cs
  • microservices/src/employee-service/Application/Employees/Employees.cs
  • microservices/src/employee-service/Program.cs

See Also​

Keywords​

  • Command handler
  • Query handler
  • Direct DI dispatch

Revision Information​

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly