unit-of-work

how to implement Unit Of Work just using just TransactionScope and sqlconnections

六月ゝ 毕业季﹏ 提交于 2019-12-23 02:43:15
问题 I am working on a existing system(asp.net 2, ms sql server 2005) where repository pattern is implemented like: IMyRepository { void add(object o); int update(object obj); int delete(object obj); IList<T> getAll(); IList<T> getByDate(DateTime date); .... } The system has 3 different products. So We have different repository for each product. As the requirement changes over time, we need to implement Unit Of Work pattern for business process level transaction. We don't have any ORM.(actually we

translate this into a generic repository pattern

不羁岁月 提交于 2019-12-22 18:27:14
问题 I have started translating a project into a generic repository and unit of work pattern. So far I have been able to reverse engineer all direct context references in the controllers to a generic repository; however, I am having trouble with the following two lines of codes: `context.Entry(ticket).Collection(i => i.TicketItems).Load(); ticket.TicketItems.Clear();` This is what my controller was doing before to remove any reference between a Ticket and a TicketItem . There is a many-to-many

Mocking UnitOfWork with Moq and EF 4.1

不问归期 提交于 2019-12-22 09:36:22
问题 I am working my way through the Contoso sample for some TDD practice and my tests for retrieving students are passing. My test for creating a new student fails (although the actual code works) as I believe the DBContext is not being mocked. What should I refactor in order to get this test to past? The test fails as so: Contoso.Tests.Controllers.StudentControllerTest.Create_HttpPost_Should_Save_New_Student: Expected: 9 But was: 8 Heres the concrete UnitOfWork public class UnitOfWork :

Why would I use the Unit of Work pattern on top of an NHibernate session?

穿精又带淫゛_ 提交于 2019-12-22 06:55:35
问题 When would I write a UoW implementation on top of what is already provided by NHibernate? Any real world examples? 回答1: The Unit Of Work you are describing is already provided by NHibernate so there is no reason to do such a unit of work. What we have in our WCF Service is a higher level unit of work that contains information important in our application for the current unit of work. This includes abstracting the NHibernate ISession for us. When you break it down you have code that fits into

best practice to implement repository pattern and unitOfWork in ASP.NET MVC [closed]

假装没事ソ 提交于 2019-12-22 00:37:42
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I am working on implementing Repository Pattern and UnitOfWork from last few days, which I have completed to upto good extend, I believe. I am sure there are plenty of ways to implement that but what I am interesting to find best approach for that. I am taking very simple

How to peek at message while dependencies are being built?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 22:41:53
问题 I building multitenancy into the unit of work for a set of services. I want to keep the tenancy question out of the way of day-to-day business domain work, and I do not want to touch every existing consumer in the system (I am retrofitting the multitenancy onto a system without any prior concept of a tenant). Most messages in the system will be contexted by a tenant. However, there will be some infrastructure messages which will not be, particularly for the purpose of automating tenant

can you have multiple transactions occur inside one session in nhibernate? And is it a bad idea?

二次信任 提交于 2019-12-21 13:17:30
问题 I'm thinking about making my own IUnitOfWork implementation for an NHibernate persistence layer. It seems that the right way to do this would be to have the ISession and the ITransaction instantiated in the constructor, and then disposed in the destructor or the Dispose() method. Of course, if someone invokes the Save() method, then the ISession would be flushed and the ITransaction would be complete, so after calling Save() , there would not be a valid open transaction to Save() again...

can you have multiple transactions occur inside one session in nhibernate? And is it a bad idea?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 13:17:06
问题 I'm thinking about making my own IUnitOfWork implementation for an NHibernate persistence layer. It seems that the right way to do this would be to have the ISession and the ITransaction instantiated in the constructor, and then disposed in the destructor or the Dispose() method. Of course, if someone invokes the Save() method, then the ISession would be flushed and the ITransaction would be complete, so after calling Save() , there would not be a valid open transaction to Save() again...

Implementing the Repository Pattern in ASP.NET MVC

三世轮回 提交于 2019-12-21 04:25:12
问题 I am still having a hard time wrapping my head around this. I want to separate my layers (dlls) like so: 1) MyProject.Web.dll - MVC Web App (Controllers, Models (Edit/View), Views) 2) MyProject.Services.dll - Service Layer (Business Logic) 3) MyProject.Repositories.dll - Repositories 4) MyProject.Domain.dll - POCO Classes 5) MyProject.Data.dll - EF4 Workflow: 1) Controllers call Services to get objects to populate View/Edit Models. 2) Services call Repositories to get/persist objects. 3)

Using DbContext and DbSet instead of implementing repositories and unit of work

杀马特。学长 韩版系。学妹 提交于 2019-12-21 02:47:31
问题 I have seen plenty of articles about implementing repositories and a unit of work. I have also seen articles about how doing this is just adding extra complexity, because the DbContext is already using the repository and unit of work pattern. I will be refactoring an application that pretty much has a repository for each entity, and would like to remove as much complexity as possible. Can anyone explain/provide links to articles/blogs/etc that explain how to use the DbContext instead of my