Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

The tag has no usage guidance.

3
votes
1answer
92 views

Repository Pattern whith complementary objects (agregates)

Refactoring an old API into a new one, because of several tools using it (admin and some mainteinance scripts) and compatibility with older versions reasons the database structure must remain the same....
4
votes
2answers
75 views

Handling disposables with dependency injection

I'm struggling to implement disposable objects via dependency injection, as the dependencies are injected in the constructor (and live as long as their containing object does), whereas I want the ...
3
votes
1answer
111 views

Should unit of work create repository?

Our "unit of work" class has a method which takes a class type and creates a repository: public IRepository<TEntity> GetRepository<TEntity>() where TEntity : class { ...
1
vote
0answers
175 views

Proper implementation of Repository Pattern with MVVM in WPF

I am currently refactoring a WPF application that is built on the principles of the Repository Pattern. It uses Entity Framework as its ORM, and is Database First. Each of those entities is wrapped by ...
0
votes
1answer
81 views

Swapping Entities or ORM in repository pattern

Lets say i am following Repository pattern in my application and i have class UserEntity { private $model; public function __construct() { $this->model = new UserModel(); } }...
-1
votes
1answer
31 views

What is the best way to use table and column names in repository pattern

My application follows repository pattern in the data access layer. However, I see, in repositories' data retrieval methods, column names and table name are hard-coded strings, which I think is not ...
0
votes
0answers
48 views

Creating a central repository for repositories with related data?

I am building a website for a fruit company. In my database I have a list of countries, and for each country, a list of distributors that sell my fruit products. The country and distributor are ...
3
votes
3answers
165 views

How can database-specific functionality, such as increment/decrement features, be used in DDD?

I have an entity that has a dollar balance property. Whenever an event occurs that causes the balance to change, such as a debit, within the same transaction the balance should be decremented by the ...
0
votes
1answer
112 views

Is invoking one repository from another a code smell?

I recently came accross an old webapp project which is using a repository layer between domain and persistance layer. However, the repository layer has been used weirdly. One example is the blog ...
1
vote
2answers
211 views

Where to place POCOs validation - N-layers architecture

I am developing an n-layer app. One of the layer is the BusinessLayer and consumes a set of POCOs defined in the CoreLayer. Also I have a PresentationLayer (WinForms) CoreLayer POCOs (classes with ...
-3
votes
1answer
95 views

Using pattern “Repository” for table relations

Have read about "Repository pattern", before it, I have used pattern DAO (data-acess-object). How should I implement table relations with this pattern? Should I create entity for links between tables?...
1
vote
2answers
83 views

How to implement Domain Model with Repository without leaking responsibility?

Imagine, we have test modules with large number of questions and we can create tests which will contain exactly 30 questions. public class Module { public long Id { get; set; } public List&...
0
votes
1answer
75 views

Hexagonal Architecture and database concurrency

I have been reading Alistair Cockburn's article on Hexagonal Architecture. One question that occurs to me, is how to handle situations where there are database concurrency issues. An obvious example ...
1
vote
3answers
789 views

Data Entities, Domain entities and the repositories

I'm trying to get my head around DDD but I'm stuck. This is how I setup my project: Data Access Layer -Entity models that map to the db -Db connection stuff -Repositories implementations Domain ...
3
votes
1answer
2k views

Generic repository pattern +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 ...
1
vote
2answers
855 views

DDD - Aggregate inheritance and repositories, how to correctly design this situation?

I'm working on a legacy warehouse system. There is one Aggregate root, Product which has its correspondent ProductRepository. Right now I have a new requirement that says the following: Some ...
10
votes
5answers
4k views

If Repository Pattern is overkill for modern ORMs (EF, nHibernate), what is a better abstraction?

I've recently read a lot of arguments against using the repository pattern with powerful ORM's like Entity Framework as it incorporates repository-like functionality, along with Unit of Work ...
2
votes
0answers
137 views

How to implement Repository that supports ORM's validation?

DDD has an abstract repository pattern to handle saving and fetching/finding entities in storage (db, external service, doesn't matter). My question is if Repository pattern has to only bring the ...
9
votes
3answers
6k views

in DDD, should repositories expose an entity or domain objects?

As I understand it, in DDD, it is appropriate to use a repository pattern with an aggregate root. My question is, should I return the data as an entity or domain objects/DTO? Maybe some code will ...
109
votes
11answers
26k views

Are (database) integration tests bad?

Some people maintain that integration tests are all kinds of bad and wrong - everything must be unit-tested, which means you have to mock dependencies; an option which, for various reasons, I'm not ...
0
votes
1answer
304 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
3
votes
2answers
193 views

Generic Repositories with DI & Data Intensive Controllers

Usually, I consider a large number of parameters as an alarm bell that there may be a design problem somewhere. I am using a Generic Repository for an ASP.NET application and have a Controller with a ...
2
votes
3answers
1k views

How to avoid duplication of code related to shared entities in the repository pattern?

I'm building a repository for a large CRM schema that has a high number of relations between entities. Some of the entities are referenced by almost all entities, e.g. Person and Company. Where I ...
3
votes
1answer
5k views

Generic repository unit testing best practice?

How can I unit test my generic repository? Unit testing code: [TestClass] public class UnitTestLanguage { private IUnityContainer _unityContainer; private IUnitOfWork _uow; private ...
58
votes
9answers
26k views

Should Repositories return IQueryable?

I have been seeing a lot of projects that have repositories that return instances of IQueryable. This allows additional filters and sorting can be performed on the IQueryable by other code, which ...
1
vote
1answer
200 views

Is it bad practise to create instances from a SQL-query?

I'm researching ways to create a OO-model/repository-layer using PHP's PDO. My idea was to create model classes that represent a domain object and a repository class for each model that has the ...
1
vote
1answer
2k views

CQRS with Repository pattern and Inversion of Control (with DI)

I assigned a POC project to someone where I asked to implement both Command Query Responsibility Segregation, Inversion of Control (with Dependency Injection) and Repository pattern. “Someone” gave ...
2
votes
2answers
5k views

Unit of work/repository pattern with dependency injection advice

I'm developing a series of repository classes and a UnitOfWork class (plus its IUnitOfWork interface of course). I'm using Castle Windsor, which injects dependencies via constructors. My business ...
1
vote
2answers
152 views

How do you handle objects that need custom behavior, and need to exist as an entity in the database?

For a simple example, assume your application sends out notifications to users when various events happen. So in the database I might have the following tables: TABLE Event EventId ...
7
votes
2answers
956 views

Should I create repositories with special functions like getStaffActive()?

I have seen lots of articles but none really help me. That is because I want to use dapper as a DAL. Should I create repositories with special functions? Like getStaffActive()? If I use repositories ...
2
votes
1answer
803 views

DDD Model Design and Repository Persistence Performance Considerations

So I have been reading about DDD for some time and trying to figure out the best approach on several issues. I tend to agree that I should design my model in a persistent agnostic manner. And that ...
1
vote
3answers
707 views

Aggregate root & Repository dilemma

I am in a big dilemma here. I have a League, Team and Player entities. I have created a repo for the league only as a Team cannot exists without a League. At first I had bounded the players only with ...
16
votes
2answers
8k views

Relationship between Repository and Unit of Work

I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once. After read several ...
2
votes
1answer
1k views

DDD: Identifying aggregate root

I am designing the a web application using Domain-Driven Design. I have following scenario: Each Application Group can have one Application and each Application can have multiple Configurations. I am ...
2
votes
3answers
318 views

Usage of repository between EF model and code consumer

I have binary data in my database that I'll have to convert to bitmap at some point. I was thinking whether or not it's appropriate to use a repository and do it there. My consumer, which is a ...
3
votes
2answers
2k views

Who's the author/creator of the Repository Pattern?

I´m pretty sure it´s not the gang of four. I have a feeling this is a newer pattern. Where was it first published/mentioned?
8
votes
1answer
6k views

Hooking up a Business Layer and Repository using Unit of Work Pattern

My question is similar to this one on Stack Overflow: What is the correct way to use Unit of Work/Repositories within the business layer? Scenario: .Net solution IRepository used to retrieve objects ...
4
votes
3answers
1k views

Usage of Repository Pattern

I'm using the Repository pattern in my application right now. It is a console-based batch processing tool. Essentially I need the repository to be able to randomly access the data. The trouble I am ...