Questions tagged [unit-of-work]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
60 views

Update Entity for Repository Pattern and UOW Pattern C#

In one mock solution, I have created 3 mock projects to implement layered architecture design mainly the - Presentation Layer (Web) - Domain Model Layer - Infrastructure Layer. I haven't yet to add ...
1
vote
2answers
273 views

How to get ORM (Ef Core) Entities follow a DDD style . Which is the best approach?

I am considering mutliple options to face a problem. I want to develop software following DDD style. The problem arise when I have to define my entities and I am working with Entity Framework Core, ...
1
vote
3answers
125 views

Tracking state on entity and unit-of-work pattern

In my web app I have a long running operation that is processing some entity in the background. The state of this process should be visible to the clients. During the processing the UI should show ...
1
vote
0answers
69 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
1answer
3k 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
868 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
612 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
1k 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 ...
1
vote
0answers
330 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
510 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
1answer
409 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
6k 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
1k 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 ...
3
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
753 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. ...
3
votes
1answer
236 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
92 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
745 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
322 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
233 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
1k 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
4k 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
198 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
548 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
671 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
746 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/...
5
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 ...
200
votes
9answers
115k 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
5k 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 ...