The repository pattern provides a way to provide isolation between the data access layer of your application with the business layer. When using this tag on implementation heavy questions - tag the code language the implementation is written in.
Questions tagged [repository-pattern]
3171 questions
584
votes
11 answers
What's an Aggregate Root?
I'm trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what an aggregate root is, I keep finding discussions…

Dinah
- 52,922
- 30
- 133
- 149
562
votes
14 answers
What is the difference between DAO and Repository patterns?
What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven Design (DDD) and Test-Driven Development (TDD) as…

Thurein
- 6,645
- 5
- 22
- 23
339
votes
11 answers
Proper Repository Pattern Design in PHP?
Preface: I'm attempting to use the repository pattern in an MVC architecture with relational databases.
I've recently started learning TDD in PHP, and I'm realizing that my database is coupled much too closely with the rest of my application. I've…

Jonathan
- 18,229
- 10
- 57
- 56
231
votes
13 answers
DDD - the rule that Entities can't access Repositories directly
In Domain Driven Design, there seems to be lots of agreement that Entities should not access Repositories directly.
Did this come from Eric Evans Domain Driven Design book, or did it come from elsewhere?
Where are there some good explanations for…

codeulike
- 22,514
- 29
- 120
- 167
229
votes
5 answers
Difference between Repository and Service Layer?
In OOP Design Patterns, what is the difference between the Repository Pattern and a Service Layer?
I am working on an ASP.NET MVC 3 app, and am trying to understand these design patterns, but my brain is just not getting it...yet!!

Sam
- 15,336
- 25
- 85
- 148
158
votes
1 answer
How are Spring Data repositories actually implemented?
I have been working with Spring Data JPA repository in my project for some time and I know the below points:
In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the…

Vasu
- 21,832
- 11
- 51
- 67
157
votes
1 answer
Difference between a Factory, Provider and a Service?
What is the difference between the terms Factory, Provider and Service?
Just getting into NHibernate and its Repository pattern (POCO classes, etc).

mrblah
- 99,669
- 140
- 310
- 420
144
votes
3 answers
Generic Repository With EF 4.1 what is the point
As i dig deeper in to the DbContext, DbSet and associated interfaces, I am wondering why you would need to implement a separate "Generic" Repository around these implementations?
It looks like DbContext and IDbSet do everything you need and include…

Code Jammr
- 1,867
- 3
- 14
- 18
133
votes
4 answers
Managing relationships in Laravel, adhering to the repository pattern
While creating an app in Laravel 4 after reading T. Otwell's book on good design patterns in Laravel I found myself creating repositories for every table on the application.
I ended up with the following table structure:
Students: id, name
Courses:…

ehp
- 1,689
- 3
- 14
- 20
102
votes
9 answers
NOT using repository pattern, use the ORM as is (EF)
I always used Repository pattern but for my latest project I wanted to see if I could perfect the use of it and my implementation of “Unit Of Work”. The more I started digging I started asking myself the question: "Do I really need it?"
Now this all…

Dejan.S
- 18,571
- 22
- 69
- 112
96
votes
4 answers
Well designed query commands and/or specifications
I've been searching for quite some time for a good solution to the problems presented by the typical Repository pattern (growing list of methods for specialized queries, etc.. see: http://ayende.com/blog/3955/repository-is-the-new-singleton).
I…

Erik Funkenbusch
- 92,674
- 28
- 195
- 291
91
votes
1 answer
Method cannot be translated into a store expression
I saw this code work with LINQ to SQL but when I use Entity Framework, it throws this error:
LINQ to Entities does not recognize the method 'System.Linq.IQueryable'1[MyProject.Models.CommunityFeatures] GetCommunityFeatures()' method, and this…

Shawn Mclean
- 56,733
- 95
- 279
- 406
90
votes
7 answers
How to use the repository pattern correctly?
I am wondering how should I be grouping my repositories? Like from the examples I seen on the asp.net mvc and in my books they basically use one repository per database table. But that seems like a lot of repositories leading you to have to call up…

chobo2
- 83,322
- 195
- 530
- 832
87
votes
4 answers
EF Including Other Entities (Generic Repository pattern)
I am using the Generic Repository pattern on top of Entity Framework Code First. Everything was working fine until I needed to include more entities in a query. I got to include one entity successfully, but now I can't figure out how to include…

Kassem
- 8,116
- 17
- 75
- 116
87
votes
1 answer
Repository Pattern - How to understand it and how does it work with "complex" entities?
I'm having a hard time understanding the Repository Pattern.
There are a lot of opinions on that topic like in Repository pattern done right but also other stuff like Repository is the new Singleton or again like in Don't use DAO use Repository or…

Stefan Falk
- 23,898
- 50
- 191
- 378