Questions tagged [repository-pattern]
Pattern that aims to manage a set of persistent objects or a database by providing an interface that emulates a collection.
140 questions
1
vote
3
answers
206
views
How to handle overfetching efficiently with repository pattern in large applications?
I'm working on a large Typescript project in NodeJS with Prisma, where we have dozens of domain entities—some with 30+ fields and complex relations.
We're using the repository pattern to abstract data ...
1
vote
1
answer
314
views
Is there a better way to soft delete navigation properties in Entity Framework 6 when using Repository pattern?
public void ReassignLineItems(InvoiceUpdateDto invoiceUpdate)
{
Invoice invoiceInRepository = _unitOfWork.InvoiceRepository
.FirstOrDefault(invoice => invoice.Id == invoiceUpdate.Id);
...
3
votes
2
answers
2k
views
What data type should a repository return?
In domain driven design, repositories are created for aggregate roots only. Does this mean that all repository methods should return an instance or a collection of the aggregate root for which the ...
1
vote
1
answer
423
views
3rd party REST API calls in repository pattern
For a long time, I’ve been using Repository pattern to abstract data access logic from actual business logic, always using SQL or noSQL databases as my data source.
But how much valid is it, to ...
2
votes
2
answers
322
views
Clean Architecture Chapter 8 - Financial Data Mapper
I’m studying Clean Architecture, and I came across a technical concept in the diagram from chapter 8. In this chapter, the author states that the Financial Data Mapper implements the Financial Data ...
-1
votes
1
answer
148
views
Passing In-Memory Specification to Repository
I am working on my DDD know-what/how and have the following questions related to the Specification Pattern, the Repository Pattern, persistence agnosticism, and performance.
Consider, for the sake of ...
0
votes
1
answer
150
views
Where to put getOrSave responsibility?
I have many repeated parts of service logic which just fetches object if it exists or returns a newly saved one.
I want to move it from service because it just clutters up the logic. But I do not ...
2
votes
1
answer
115
views
What is the correct way to configure a testing mode on a class?
I have a repository which reads and writes to Firestore, and some tests to make sure data is sent and comes back in the correct way.
In order to test this I added a protected function which returns ...
3
votes
1
answer
219
views
How to structure repositories for a small number of entities?
I am working on a project implemented in DDD style, and I use Repository architecture pattern to persist domain changes. I have multiple roles in domain layer, and that's what raises my question - how ...
0
votes
2
answers
203
views
Repository concerns
We have a layered application with (basically): WebAPI, App Services, Domain and Repository layers.
This fits for most situations, but now we face a slightly different challenge on where we need to ...
1
vote
4
answers
505
views
How to Access the Private State of an Entity in the Save Method of its Repository
Consider the domain entity, Order, which can be persisted by the OrderRepository. Orders maintain state that is stored in the database. However, it does not expose all of it directly. That is, parts ...
3
votes
9
answers
5k
views
Is it an anti-pattern to use interface for entity?
I read an article about that using an interface for an entity is an anti-pattern for these reasons:
Your interface signature is identical to your class.
There’s only one implementation of your ...
2
votes
1
answer
378
views
How to properly use Data Transfer Objects
I feel something is wrong with my approach handling MVP and the Repository Pattern. I'm making an album winform app just to practice MVP, crud and the Repos. Pattern.
First some code.
The model:
using ...
4
votes
3
answers
1k
views
Should I save my entire domain object or update individual properties?
Scenario:
An application is going to perform operations on an entity. That means retrieving it from storage, possibly making modifications, and then persisting those changes back to storage.
I'm ...
3
votes
3
answers
2k
views
How to implement Repository if only part of Entity properties are needed?
From many articles and answers on DDD Repository pattern, I got the feeling that a Repository should only CURD an Entity (Aggregate Root) as a whole.
Following this convention, we always need to query ...