代码改变世界

Nhibernate Beginner ch12 odds and ends

2011-07-12 01:47  一一九九  阅读(211)  评论(0编辑  收藏  举报

Unit of work and burrow

        Unit Of work pattern: http://www.martinfowler.com/eaacatalog/unitOfWork.html

         when  you’re pulling data in and out of a databased, it’s important to keep track of what you’ver changed.Otherwise,  that data won’t be writtern back into the database. Similary, you have to insert the neww objects you create and remove any objects you delete.

          in our traditional model, creating an order would involve somthing like this:
          1. create bill/ship cont
          2. create order header | associate Contacts;
           3. create order items | associate to order header.
           4. Total Order Items, Update Order Header.
Eache of thease actions would most likely be performed in a discrete database transaction.
In a Unit of Work pattern, “Insert a new Order ” would be a single unit of work. Each of the items required to create or modify the order would be gathered and the save or update actions would take place only when that particular Unit of Work needs to be persisted.

In order to implement this pattern using the NHibernate session, we  need to decouple ourseleves from the ASP.net  stateless postback model, because to create an order, we might need to retrieve data from several pages in order to construct our order.

one of the frameworks you can use to help implement this pattern is the Burrow framework, which helps to provide stateful nhibernate session management in asp.net.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

act.