Questions tagged [repository]

For questions about the implementation of the repository design pattern.

Filter by
Sorted by
Tagged with
38 votes
2 answers
3k views

KISS my... unit of work

I've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity. Sure the complexity buys you (sometimes) full decoupling ...
user avatar
28 votes
2 answers
15k views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
user avatar
  • 409
24 votes
0 answers
3k views

Repository pattern in Rust

I'm looking to add a thin layer of abstraction for database interaction in my application. I'm not really looking for a full blown ORM or advanced query builder. I am familiar with Diesel, but its ...
user avatar
  • 561
15 votes
2 answers
39k views

Unit of work + repository + service layer with dependency injection

I am designing a web application and a windows service and want to use the unit of work + repository layer in conjunction with a service layer, and I am having some trouble putting it all together so ...
user avatar
14 votes
2 answers
1k views

YARPI: Yet Another Repository Pattern Implementation

Following-up on this post, I wanted to be able to put a copy of that Excel workbook on a USB key and take it home to keep working on the code a bit (there's more than just one or two tables to ...
user avatar
13 votes
5 answers
13k views

Is this Repository Design Pattern Valid and efficient?

I am using Dapper ORM in my Data access Layer, but I think analysis of the code below doesn't depend upon any specific ORM. What should be the single common place throughout the entire Data Access ...
user avatar
  • 231
13 votes
5 answers
19k views

Disposing the Context in the Repository pattern

I have a question about the Repository pattern: ...
user avatar
12 votes
1 answer
7k views

Onion Architecture

After doing a whole bunch of research on Onion Architecture, I have made an attempt at implementing this in a new system that we are developing. We have the Layers as per below: Domain ...
user avatar
12 votes
2 answers
303 views

Something like a LINQ provider

Ok, before you ask: yes, I need to do this. Sort of. I'm wrapping a 3rd-party API for data access, and I can't use an ORM, so I'm implementing this kind of thing: ...
user avatar
10 votes
2 answers
15k views

Manage connection without 'using' statement

I replace this common statement: ...
user avatar
10 votes
2 answers
181 views

Disposable Heroes

I had a bit of an issue with my last piece of code, having to do with cleaning up resources. I needed a way to ensure the database connection was always properly closed, even if there still were ...
user avatar
10 votes
1 answer
1k views

Repository Pattern without an ORM

I'm trying to learn the Repository pattern, and I have some questions regarding my current understanding of it. All the examples I've been able to find of database repositories use ORMs, but for a ...
user avatar
  • 101
8 votes
1 answer
12k views

MVC 5 & EF 6 - Repository & Unit of Work Pattern

I have been looking through Code Review on the subject of Unit of Work and Repository patterns and realised that my implementation appears to provide very similar functionality but in reverse class ...
user avatar
8 votes
1 answer
20k views

EF Generic Repository + Unit of Work pattern with support for Async

I'm working on a generic repository using EF 6 code first and trying to following the Unit of Work pattern. Unity is being used to inject my repositories, and I'm trying to get everything supporting ...
user avatar
  • 183
8 votes
1 answer
6k views

Service-Repository pattern with IoC, NPoco micro-ORM and unit tests

I'm trying to build a Web API using best practices, based on a simple proof-of-concept using students. My goal is to build the system using: Onion Architecture to seperate concerns. Service-...
user avatar
  • 621
8 votes
1 answer
1k views

Building multi-source Repositories and Units of Work

I am working in a shop where we tie into multiple different vendors to share data. I am also tasked with "bringing the code base up to the 4.x framework". To start, I understand that Entity ...
user avatar
7 votes
2 answers
24k views

Implementing repository pattern and DAL with stored procedures

Using .net 3.5, implementation of the repository pattern along with enterprise library 5 and stored procedures. Did not use EF, stored procedures already available and VS2008 is limited to EF 3/4. ...
user avatar
  • 235
7 votes
2 answers
21k views

C# - Entity Framework + Repository pattern + Unit of work pattern

After hours spent on reading various articles about correct way to implement Repository patter & UoW patters I finally think that I have managed to create (hopefully good) implementation. The ...
user avatar
  • 231
7 votes
1 answer
1k views

UnitOfWork, an excuse for multiple repositories

I needed a way of attaching multiple repositories to a presenter. Given I already had an IRepository abstraction, coming up with an ...
user avatar
7 votes
1 answer
4k views

Fluent Repository/QueryBuilder

I've been toying around making my repositories a bit more fluent for a while. I was ending up with crazy long method names when I had to query on multiple conditions. So I've been working on a way to ...
user avatar
6 votes
2 answers
288 views

Repository implementation

I have a repository called PostsRepository: ...
user avatar
6 votes
1 answer
74 views

Wrapping the Sage300 View API with... a Repository

Related: Something like a LINQ provider I needed to work with the Sage300 View API. I had never worked with it, but my first impression has been that the API is ...
user avatar
6 votes
1 answer
10k views

Unit of Work / Repository nHibernate

I have a Unit of Work / Repository pattern in place to abstract away some nHibernate. Most examples I've seen though use the pattern a little differently. In ...
user avatar
  • 161
6 votes
1 answer
92 views

Expiring key/value repository. Java

The following code is in-memory repository that stores key/value pairs. It will be used on our server to keep information about active clients. Clients send keepalive messages to indicate that them ...
user avatar
  • 257
6 votes
1 answer
8k views

Identity repository pattern with unit of work

I am creating simple web api/ SPA application using EntityFramework, IUnitOfWork, Repository pattern, Unity DI along with Asp.net Identity. Unity configuration ...
user avatar
6 votes
2 answers
2k views

Web API using Repository / UnitOfWork

I'm looking for feedback on a repository I set up based on a blog post I read here. I have just recently got more into .NET within the past year, so any feedback and/or best practices that can be ...
user avatar
5 votes
3 answers
2k views

Unit of Work Pattern for creating users

CreateUser function assumes the data being delivered via parameters are clean and gets called or initiated from the Business Manager (another class). This function is responsible to do the following ...
user avatar
5 votes
4 answers
2k views

Generic Repository For Web Apps

I was developing a web app using Entity Framework 6 and MVC 5. For the data access layer, I eased the job and wrote a generic repository as following: ...
user avatar
  • 179
5 votes
2 answers
2k views

Should i throw exceptions in the service layer or repository, and catch it on the controller? [closed]

I read some answers here on stack exchange, but none really "hits the nail on the head" about where to throw exceptions, where I shouldn't and where to catch them. the idea that an exception ...
user avatar
5 votes
2 answers
6k views

EF6 Code First unit of work pattern with IoC/DI

I'm trying to implement the unit of work pattern with dependency injection / inversion of control and entity framework version 6.1.1 Code First, in an asp.net-mvc project. ...
user avatar
  • 179
5 votes
1 answer
13k views

Repository pattern best practices using EF 6

I have been Googling for a few days and am trying to find the best practices when it comes to using the Repository pattern. But what I found that there are no standards and everyone claims that their ...
user avatar
  • 259
5 votes
3 answers
5k views

Generic repository pattern

Please have a through look my custom implementation of generic repository pattern and suggest anything I may be lacking. I am using a generic interface with 6 methods I'll be using a repository class ...
user avatar
  • 51
5 votes
2 answers
7k views

Laravel - Repository and Entity patterns

I've spent quite a bit of time studying the repository and entity patterns and this is what I came up with. I would appreciate it if you could post suggestions and critique. ...
user avatar
  • 235
5 votes
1 answer
8k views

Cached repository implementation for small lists of data models

I have been using Repositories in my ASP.NET MVC projects and I felt the need to fully cache small tables data (dictionaries, cities, countries etc.). This kind of information is changed (very) ...
user avatar
  • 1,786
5 votes
2 answers
7k views

Unit of work Repository pattern DBcontext EF-Entities and ninject

I am totally confused while implementing Repository pattern with unit of work and Entity framework because I have seen tons of examples. Please suggest whether I am on the right track or not. ...
user avatar
5 votes
2 answers
4k views

Repository pattern along with EF and Unit of work

I'm new to this Repository pattern and have seen lot of repository pattern + UoW implementations all over the internet and I'm not able to reach to a conclusion as to which of them is correct . After ...
user avatar
4 votes
3 answers
2k views

Pass IEnumerable<T> as an argument of method and repository pattern

I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use ...
user avatar
  • 553
4 votes
2 answers
2k views

Repository pattern with Unit of work using ADO.NET in C# to authenticate user from database

So I am using the latest version of Dapper and it works great for mapping my POCO classes but there are some scenarios where I need to return a DataSet instead of ...
user avatar
4 votes
3 answers
173 views

Method that fetches rows from database and maps it to a Model class with SqlDataReader

So, I have a project that has a lot of methods that look alike. In the below method as you can see it just fetches a bunch of rows from database and maps it to a model class. In this case ...
user avatar
4 votes
1 answer
189 views

User controller for a .net core WebAPI dating app

I have this user controller that follows the repository pattern. It works perfect, but is it easy to understand? Is this good quality work? ...
user avatar
  • 41
4 votes
1 answer
14k views

Generic Repository without Entity Framework

Almost all of generic repository pattern tutorials were making use of EF, so I haven't got much sources to compare my code with. Here is what I have done. Could you please suggest me to fix my wrongs ...
user avatar
  • 131
4 votes
2 answers
356 views

Mix of Repository and UOW For Business Library with Entity Per Table Architecture

I am trying to use Entity framework along with UOW in business class where I want to use this layer across multiple types of applications like web, webapi and Windows Services. So I cooked something ...
user avatar
  • 141
4 votes
1 answer
637 views

eCommerce project using the Repository pattern

I am currently working on an eCommerce project in Laravel 5.1. I have implemented Repository Pattern by learning from this site only for 1 model, namely, ...
user avatar
4 votes
1 answer
856 views

Event sourcing with Python

I've been studying the event sourcing pattern and trying to come up with a set of classes or minimal library I can share across projects. Below you can find the implementation of this main parts of ...
user avatar
4 votes
1 answer
2k views

Choose the right type for method GetById

I designed my repository class and I need some advice from you. Now I have a method GetByID that returns a generic type: ...
user avatar
4 votes
1 answer
727 views

My implementation of the repository pattern

I'm using this pattern since a few months and I was wondering if I can make it any better. The one thing I am not satisfied about is the dispose method. In every repository I have to add a dispose ...
user avatar
  • 43
4 votes
1 answer
5k views

Returning IQueryable<T> from my repository in Repository pattern design pattern

I am developing an application based on Repository design pattern. What should be the return type from the Repository? This is my UserRepository class: ...
user avatar
4 votes
1 answer
316 views

Saving a sales order - too many repositories?

I am wondering if I have overdone it with repositories in the following code, which is to save a sales order. I understand that the purpose of a repository is to decouple the domain layer from the ...
user avatar
  • 423
4 votes
1 answer
884 views

Ruby Repository Pattern

I am trying to teach myself about repository pattern in ruby. Could you please review my code. adapter.rb ...
user avatar
  • 173
4 votes
0 answers
74 views

Is there a better way to unit test a repository for a large aggregate root?

In our project we use domain-driven design and our customer aggregate root is large. The unit tests for the aggregate root itself are simple (~50 or so tests), but I am struggling with the repository ...
user avatar