If anybody can share a link in which Unit of Work pattern is fully implemented in C#? (not using NHibernate or Entity framework)
The Unit of Work pattern is used to group one or more operations (usually database CRUD operations) into a single transaction or “unit of work” so that all operations either pass or fail as one unit.
The SI unit of work is joule (J). Joule is defined as the work done by a force of one newton causing a displacement of one meter. Sometimes, newton-metre (N-m) is also used for measuring work. However, as this unit is also used for torque it can get quite confusing.
The unit of work class serves one purpose: to make sure that when you use multiple repositories, they share a single database context. That way, when a unit of work is complete you can call the SaveChanges method on that instance of the context and be assured that all related changes will be coordinated.
Unit of Work is the concept related to the effective implementation of the repository pattern. non-generic repository pattern, generic repository pattern. Unit of Work is referred to as a single transaction that involves multiple operations of insert/update/delete and so on.
Check out Ritesh Rao's NCommon https://github.com/riteshrao/ncommon Or Ayende's Rhino Commons http://www.ayende.com/Wiki/Default.aspx?Page=Rhino+Commons&AspxAutoDetectCookieSupport=1 Or here is an article on implementing UOW by Jeremy Miller http://msdn.microsoft.com/en-us/magazine/dd882510.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With