unit-of-work

Using Unit of Work design pattern / NHibernate Sessions in an MVVM WPF

I think I am stuck in the paralysis of analysis. Please help! I currently have a project that Uses NHibernate on SQLite Implements Repository and Unit of Work pattern: http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/10/nhibernate-and-the-unit-of-work-pattern.aspx MVVM strategy in a WPF app Unit of Work implementation i...

Unit of Work pattern and persistence

Hello, I have been reading about Unit of Work pattern but I am confused about how the UoW actually persists data. When we commit the changes, UoW should iterate through the list of Added, Updated and Deleted objects and somehow find a class responsible to Add, Update, Delete objects of a certain type. I couldn't find an example sho...

How does Active Record pattern go a long with a Unit of Work pattern

I'm working on extending a framework currently implementing an Active Record pattern. The implementations provides a store/save method on the ActiveRecord class. I guess much of this implementation would be the responsibility of the unit of work implementation, like figuring out when and what object relations to save and so on? How doe...

Is the Entity Framework 4 "Unit of Work" pattern the way to go for generic repositories?

I am looking into creating an Entity Framework 4 generic repository for a new ASP.NET MVC project i am working on. I have been looking at various tutorials and they all seem to use the Unit of Work pattern ... From what i have been reading, EF is using this already within the ObjectContext and you are simply extending this to make your ...

NHibernateUnitOfWork + ASP.Net MVC

Hi Guys, hows it going? I'm in my first time with DDD, so I'm begginer! So, let's take it's very simple :D I developed an application using asp.net mvc 2 , ddd and nhibernate. I have a domain model in a class library, my repositories in another class library, and an asp.net mvc 2 application. My Repository base class, I have a construct...

What is the meaning of "Unit of Work" concept in NHibernate and other ORMs?

What is the meaning of "Unit of Work" concept in NHibernate and other ORMs? ...

How do I implement repository pattern and unit of work when dealing with multiple data stores?

I have a unique situation where I am building a DDD based system that needs to access both Active Directory and a SQL database as persistence. Initially this wasnt a problem because our design was setup where we had a unit of work that looked like this: public interface IUnitOfWork { void BeginTransaction() void Commit() } and o...

Validation strategy for the unit of work pattern

When I use the unit of work pattern (with JPA), I get an entity from a repository, modify it and save the modifications at the and of the unit of work implicitly to the database. Now I wonder how to perform validation with the unit of work pattern. If I apply changes (from user input) to a domain object and validate after that, the val...

Is it possible to implement Separated Interface in PHP?

I recently asked a question regarding the resolution of dependencies between Unit of Work and Data Mapper classes: http://stackoverflow.com/questions/3012657/dependency-injection-and-unit-of-work-pattern - (which was answered by Gabor de Mooij - thx) In PoEAA, Martin Fowler suggests using Separated Interface to manage these dependencie...

How to get list of changed (dirty) entities from Nhibernate session?

I need to write some business logic rigt before flush against all changed entities. One of the solution I've tried is IPreUpdateEventListener. But this event listener already have object denormalized to key-value. I need something before denormalization and even before flush. So the questions is how to get list of changed (diry) entitie...

NHibernate ISession and automatically flushing/committing transactions in my unit of work.

I have created an IDbContext object that is provided to my IRepository implementations. The DbContext provides a way for my business logic to create, commit and rollback transactions and commits as needed. It also transports my NHibernate ISession, so my NHibernate implementation of IRepository can access it. I am using this setup in a ...

Repositories and Units of Work - which is responsible for what?

Over the past week or so I have been reading a lot of articles and tutorials regarding the repository pattern. A lot of the articles closely tie the repository pattern to the unit of work pattern. In these articles, I usually find code similar to this: interface IUnitOfWork<TEntity> { void RegisterNew(TEntity entity); void Regis...

Unit of Work pattern, getters, setters and contracts (PHP)

I'm not sure if the title is the best way to describe this question. This book - http://apress.com/book/view/9781590599099 - illustrates an implementation of the Unit of Work pattern. It goes a little something like this. class UoW(){ private array $dirty; private array $clean; private array $new; private array $delete; ...

Lose databinding possibilities with UoW pattern in Linq to Sql

I'm currently working on my first Linq-to-Sql app. I've implemented the data-access methods with a short dataContext lifetime like this: public IProduct GetByCode(string code) { using (var db = new dataContext()) { return db.Products.SingleOrDefault(e => e.Code == code); } } I'm wondering how to get change notif...

How to handle exception in Flush phase?

Hi, how can I handle exception that is thrown in NHibernate method Flush? I have a action for deleting objects. It loads the objects from repository using posted ids and calls repository.Delete(obj). Leaving aside that my mapping in NHibernate is not complete and the delete results in "The DELETE statement conflicted with REFERENCE cons...

Auditing NHibernate Unit of Work with Create/Update Date

I'm using Ayende's method (http://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-ipreinserteventlistener.aspx) to set the create and update date on entities with Listeners, but it's only setting them for the entity being affected, not anything else in the unit of work. So, for example, if I do this: Order ord...

What's a good way to handle entities within an aggregate that persist to multiple databases

Hello everyone! I'm dealing with a design problem that I'm sure has a simple answer and/or has been solved before. I've been reading, thinking, and searching for solutions for quite a while, but nothing seems to really make sense. The gist of the issue is that I'm dealing with a series of legacy systems and databases and I'm trying to t...

Async read from nhibernate in web context

In a web application, I want to cache heavy calls into the db. So I want to do ansyc reads, store the result from read and transformation in a store and present the newest data I have available at the time of the request (sometimes stale) // that is the entry point public virtual IViewData DetailByKey(string key) { var articleDetail...

Unit of Work with multiple Data Sources?

It's possible (even probable) that I'm just not fully grokking the concept of a "unit of work." Basically, I see it as sort of a broad transaction used in an object-oriented environment. Start the unit of work, interact with the objects, commit or roll back. But how does this break down to the actual transactions on the data stores be...

Domain Design class decisions

I am creating a simple web site to get more familiar with MVC 2.0. I've been doing web forms since 1.0 and getting ready to start a major overhaul of a web forms site to MVC. So want to build a smaller app to work out the learning curve. So I'm going to build a time tracking application. I'm using ASP.NET MVC 2.0 and LINQ to SQL. I pl...