Skip to main content

Leave Repository and Unit of Work

Summary

Domain repository ports are implemented by one scoped DbContext and committed through a thin unit of work.

Audience

Backend developers, QA, architects, and data-focused engineers.

Overview

Ports cover requests, balances, Holidays, weekly offs, Leave types/policies, carry forward, encashment, employee profiles, and timeline. Repositories support targeted retrieval, overlap checks, add/remove, replacement, upsert, and composable queries.

No explicit AsNoTracking is used in reviewed Leave repositories or queries; reads are tracked by default. Save semantics are one DbContext SaveChangesAsync, which also translates queued aggregate domain events to outbox rows. Audit/timeline entities added before the save participate in the same local commit.

Application workflows may save a request and then save balance or external-Workflow linkage separately. Cross-service calls cannot share the local transaction. Cross-entity validation occurs in application services and repository queries rather than a centralized validation pipeline.

Source References

  • microservices/src/leave-service/Domain/Repositories.cs
  • microservices/src/leave-service/Infrastructure/Persistence.cs
  • microservices/src/leave-service/Infrastructure/LeaveDbContext.cs

See Also

Keywords

  • Leave Service
  • Leave Repository and Unit of Work
  • Technical architecture

Revision Information

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