Abstract Repository Combining Two/Multiple Repositories (OrderDocumentRepo)

Published: (January 7, 2026 at 10:15 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

In this approach, you create an OrderDocumentRepo that combines both the OrderRepo and DocumentRepo into a single abstract repository, managing the transaction within this repository.

Pros

  • Single Responsibility – Encapsulates the entire transaction logic related to both orders and documents within one repository, making it easy to manage.
  • Consistency – Ensures that order and document operations are tightly coupled within the same transaction scope, reducing the risk of partial failures.

Cons

  • Complexity – The repository handles more than one entity, potentially violating the Single Responsibility Principle.
  • Tight Coupling – Couples OrderRepo and DocumentRepo, making independent reuse or testing harder.
  • Scalability – Adding additional repositories to the transaction requires modifying OrderDocumentRepo, reducing flexibility.

Best Practice

  • Use this pattern when operations on orders and documents are always tied together and never operate independently.
  • It is useful when you need to guarantee consistency between two closely related repositories where changes are always made in tandem.

Reference

Abstract Repository Combining Two/Multiple Repositories (OrderDocumentRepo)

Back to Blog

Related posts

Read more »

C#.NET - day 04

Step 1.5 : Introducing the Repository Pattern Separating responsibilities to build systems that scale Introduction The core idea of this step is perfect separa...