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
214
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 ...
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 ...
2
votes
2
answers
328
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 ...
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 ...
3
votes
1
answer
220
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 ...
1
vote
4
answers
512
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 ...
2
votes
1
answer
384
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 ...
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 ...
1
vote
3
answers
2k
views
Using Repository Pattern with .NET Entity Framework with a single Get method with optional parameters for each table include
We have a very messy data repository component, with dozens of methods to interface a DbContext (entire database) in Entity Framework.
It was (and is) coded in a way that adds a new repo method for ...
1
vote
1
answer
2k
views
Generic Repositories with different IDbConnections
I have two different connection strings for two different databases.
My first database has 2 relational tables:
First table has some default fields,among which average on UI, and some additional ...
1
vote
0
answers
473
views
Where/how does the conversion of entity objects to data transfer objects take place in Clean Architecture?
Prolog:
I have a domain-layer which contains some entity-classes like Customer.
I have a application-layer which contains some data transfer object classes like CustomerDto.
My Problem:
At a presenter ...
5
votes
3
answers
1k
views
Are repositories async?
Repositories in ddd should give the illusion of an in memory
collection.
and
A Repository is essentially a facade for persistence that uses
Collection style semantics (Add, Update, Remove) to supply ...
4
votes
2
answers
2k
views
How to manage the entity which have collection of child entities in DDD?
A play arena contain a list of Machines and Amenities
playArena :
guid : GUID
name : string
location: Location
owner: string
amenities: Amenities
playing_machines: PlayingMachines
...
1
vote
3
answers
1k
views
Design pattern for persistent data storage - load and save arbitrary file, database, api etc
I have the following problem - I write the code for object data manager, and one of requirements is being able to save/load data into some persistent data storage. I want to make it as the following:
...
0
votes
1
answer
973
views
How to conform two repositories that work on the same entity but have different methods?
I have to implement 2 use cases, the first one is going to create a Company profile from its document number, so inside the use case, it reaches out to the third party API that contains information ...
0
votes
1
answer
322
views
In a layered architecture with exchangable data providers, how to deal with provider-specific implementation details?
Assume an application architecture with three layers (presentation, domain, data access - though presentation is irrelevant to this question) that follows dependency inversion:
The domain layer ...
11
votes
2
answers
18k
views
To which Clean Architecture layer should repositories implementations belong?
It's very common to see this use of repository in projects using clean architecture:
interface Hero { }
interface HeroRepository {
findById(id: number): Hero;
}
class FetchHeroUseCase {
...
0
votes
0
answers
42
views
Retrieving related information using the repository pattern [duplicate]
I'm currently working on refactoring a project to use the repository pattern, but I'm currently struggling with how related information should be retrieved.
Let's say I have a Hotels and Rooms. I have ...
0
votes
2
answers
2k
views
Obtaining application generated ID from repository or from entity constructor?
In the Book "Implementing Domain-Driven Design" the author suggests to implement a repository method to provide the next application-generated (not database-generated) ID. Like so:
class ...
1
vote
3
answers
2k
views
Some thoughts on the Repository pattern
Until this moment, I have seen a lot of variations and combinations of the Repository pattern, implementations that simply queried the required information, some used something like a mapper, some ...
3
votes
1
answer
908
views
CRUD is too simplistic for my usecases, how would you handle the repository pattern when using MediatR and EF Core?
I have a .Net 5 Web API project and use MediatR to encapsulate my business logic into commands and queries since I don't like to have a single CRUD service handling everything related to a specific ...
1
vote
1
answer
486
views
C# Design for database queries and commands
Currently I'm working on a project that will interact with a database. Based on my research, I would like to develop a repository class which responsability is to write/extract entities to/from a ...
3
votes
1
answer
473
views
Managing Documentation / Source Control for a Full-Stack Application Across Multiple Repos
TL;DR
I have a moderately sized/complexity web application (Angular 11) in one repo and a standalone REST API (.NET Core 3 / C#) in another repo, and am trying to figure out the most efficient way to ...
1
vote
1
answer
167
views
Deisgn Pattern: How to map UI requests to Controllers to Services?
I'm learning about writing WebApi design patterns.
I am trying to create a simple CRUD web app with ReactJS UI and C# .NET CORE webapi with sql backend.
Articles show that specific Repositories are a ...
0
votes
1
answer
4k
views
Best practice for pulling bulk data from APIs and storing in database
I have written a small application using ASP.NET Core to create and manage collections of cards for a collectable card game. I currently have a version that successfully downloads bulk card data via ...