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

Questions tagged [unit-of-work]

The tag has no usage guidance.

1
vote
0answers
50 views

Should a UnitOfWork contain every Repository?

I'm trying to get the Repository/UnitOfWork pattern figured out. We're working on a project with EntityFramework and our DBContext contains 200+ tables. Right now our approach is to inject whatever ...
3
votes
0answers
1k views

Unit Of Work with multiple database context

I have created an application (net core 2 & ef core) with Unit Of Work and Generic repository pattern. I used to have one database context but due to some business logic I had to create a second ...
1
vote
2answers
342 views

Unit of work + repository pattern + dependency injection

I am in the process of refactoring and improving a codebase. One of the major missing features is transactional safety and certain errors arising from each repository having its own DbContext. The ...
4
votes
1answer
410 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
752 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
0answers
27 views

How to handle sharing of same context in Repositories-Unit of Work when using dependency injection

I have a problem that knocks out me. Background: I am inside the devolpment of a WinForms app that is not layered. Almost all the events are handled in the Form class. I have multiple IRepositories. ...
0
votes
0answers
93 views

Unit of Work, Factory and Lifetime Management

Yesterday, an argument arose in the office, on the usage of a unit of work versus a DbFactory producing these. To give a bit of a context, we have a (loosely) service-oriented architecture, following ...
0
votes
0answers
42 views

Repository Unit of Work object type reference

I'm confused on how to best use this pattern. I have a project that uses Devart's Entity Framework for Oracle. The context is provided by them. So I have an interface IRepository and a single ...
1
vote
0answers
245 views

Putting UnitofWork handler in the Request Model for DDD with Clean architecture?

I'm rearchitecting a system in Python, using SQLAlchemy for the data mapping layer, and the Zope Component Architecture for dependency injection and interface declaration. I am in the process of ...
1
vote
1answer
353 views

Making UnitOfWork testable

I'm in the process of refactoring legacy code. Unfortunately it is a WebForms application with very tight coupling and smelly code. Currently access to database is inside models which looks something ...
0
votes
0answers
292 views

In Automotive Spice domain, how can a software unit be unequivocal defined?

Automotive Spice v3.0 do not directly define the software component and software unit but gives workflows hinting to their definition as follows: Software component: The software is decomposed ...
0
votes
1answer
359 views

Do I need to use the Unit of Work pattern with a many to many relationship?

Please see the DDL below: create table Person (ID identity not null, varchar(name), Gender char(1), dateofbirth datetime, primary key (id)) create table PersonOffer (PersonID int not null references ...
1
vote
2answers
4k views

Should I mock Repository and Unit Of Work for Unit Testing?

I have read this article: https://www.gaui.is/how-to-mock-the-datacontext-linq/ Since this article is almost 4 years old I have no hope that in article's comments my question will be answered so I ...
0
votes
2answers
728 views

Asp.Net Mvc 5 / Web Api 2 unit testing data access layer

Let's say I have IRepository interface implemented by Repository class(uses database context to implement IRepository methods). And IUnitOfWork interface implemented by UnitOfWork class using ...
4
votes
1answer
2k views

Is Unit of Work valid under a service pattern?

I've been studying design patterns. I've learned about Repositories, Unit Of Work, Dependency Injection, MVC. I'm now learning about Service Layer pattern. I'm trying to grasp the utility purpose of ...
4
votes
1answer
1k views

Implementing unit-of-work for multiple storage types

I'm trying to implement the unit-of-work pattern for mutliple storage types like the windows registry, a database or the app.config but I cannot figure out how to do it. All examples I find use Entity ...
0
votes
2answers
715 views

Best design pattern for two specific scenarios, the first one fits neatly into a Unit of Work(UoW) pattern

I have a question about what the best design pattern to use would be. I have 2 specific scenarios, the first one fits neatly into a Unit of Work(UoW) pattern. The second is a little bit more fiddly. ...
0
votes
0answers
129 views

Should I design my Unit-Of-Work like this?

I am using .net and Entity-Framework (EF) on the back end and I would like some advice on this Unit-Of-Work (UoW) implementation. Should I create a unit of work with one entity and multiple services? ...
3
votes
1answer
223 views

A “sort of” Units of Unit of Work

I've read Unit of Work pattern and tons of MVC/EF Unit of Work examples but what I'm trying to do is encapsulate multiple unit-of-work into a large set. Maybe this pattern already exists somewhere, ...
1
vote
0answers
88 views

Can NHibernate's ISession be considered as implementation of unit of work pattern?

I am debating this with myself. Does NHibernate's ISession offer a proper and correct unit of work if used without a transaction? In absence of a transaction, every SQL command would be wrapped by the ...
7
votes
2answers
690 views

How to decide what forms the System Under Test

Ok, so we started with the initial version of "The Art Of Unit Testing" and we do unit tests for classes where every test covers one aspect of one method. This has the drawback of high maintenance ...
0
votes
1answer
304 views

Sharing core repository and object mapping logic between Unit of Work methods

I'm wondering if there is a better way to do this or if I'm doing some anti-pattern here. Like I say in the subject, I'm trying to share repository calls and object mapping logic between Unit of Work ...
0
votes
1answer
204 views

How is the UnitOfWork pattern related to Monadic programming?

Looking over the definition of the Unit of Work pattern it seems very much like what a programmer would get if they implemented a Monad such as an IO or Transaction Monad. What makes the unit of work ...
1
vote
1answer
894 views

MockRepository vs Test Database for Unit Testing

Before starting, this question is not the same as this one. Comming from a PHP background, my experience is in CakePHP, which is a framework that supports Unit Testing by setting up a local test ...
5
votes
1answer
3k views

Unit of Work Concurrency, how is it handled

I am reading some information about the Unit of Work pattern. There is one thing that is not very clear for me: what will happen when you request a couple of records on a thread (1) and another thread ...
0
votes
1answer
174 views

How to save entities relations using unit of work pattern

I use Unit of work pattern to commit all new, dirty, deleted entities to the DB (using a db_mapper). Example of entities are: Student and Class So Student->registerDirty() will add this entity to ...
4
votes
2answers
2k views

Should I have separate units of work for each EF bounded context?

I have some EF bounded contexts like follows public class BoundedContext_1 : DbContext { IDbSet<A> As { get; set; } IDbSet<B> Bs { get; set; } } public class BoundedContext_2 : ...
4
votes
2answers
512 views

Communication/Updates between units of works/entity framework contexts, colliding with user changes

I'm developing a WPF application using Entity Framework for my database communication. The application has a hierarchy of tabs where each tab has a db context. Each tab allows the user to view some ...
2
votes
1answer
658 views

Would this be a correct way to use the Repository pattern in ASP .NET MVC application implementing Entity Framework?

This ASP .NET MVC application implements Entity Framework. I've declared the repositories in the DbContext like this: public class CompanyDbContext : DbContext { // constructor goes here ...
1
vote
1answer
697 views

Are there any concerns with using a static read-only unit of work so that it behaves like a cache?

Related question: How do I cache data that rarely changes? I'm making an ASP.NET MVC4 application. On every request the security details about the user will need to be checked with the area/...
4
votes
4answers
1k views

Unit of Work pattern

I have gone through many articles and I am still confused whether to use the Unit of Work pattern or not. I use generic repositories (Repository Pattern) but if my understanding of the UOW pattern is ...
2
votes
2answers
6k 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 ...
190
votes
9answers
108k views

Why shouldn't I use the repository pattern with Entity Framework?

During a job interview, I was asked to explain why the repository pattern isn't a good pattern to work with ORMs like Entity Framework. Why is this the case?
3
votes
3answers
3k views

How to use the unit of work and repository patterns in a service oriented enviroment

I've created an application framework using the unit of work and repository patterns for it's data layer. Data consumer layers such as presentation depend on the data layer design. For example a CRUD ...
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 ...
4
votes
3answers
4k views

Unit of work principle is causing a problem in MVC3 application

I am implementing a website using MVC3, Entity Framework 4.1 and Repositoty pattern, Unit of work principle. But I am facing a big problem while implementing this. I have developed a static ...
1
vote
2answers
2k views

Why is the Unit of Work pattern considered fast and efficient when working with an ORM?

In working with Doctrine 2 I came across the following paragraph. In fact, since Doctrine is aware of all your managed entities, when you call theflush() method, it calculates an overall ...
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 ...
6
votes
1answer
127 views

Data services methods naming

When you work with ORM which implement UnitOfWork pattern (NHibernate's Session, Entity Framework's ObjectContext, etc.), there are two types of data services methods: those which save/commit changes ...