views:

239

answers:

2

How transaction should be handled while using Unit of Work pattern in a WinForm application

  1. Should new UOW session be created when form is initialized?
  2. Disposed when form is exited?
  3. call UOW.commit() in every save?

Please advice

Any articles on this topic??

A: 

We put a unit of work on the form/user control. Do all necessary methods then have the user call a save button. Then dispose the UOW when the form is closed.

NotDan
+1  A: 
  • I would try to discover the use-cases/tasks that the user realises in the UI.
  • Each of these use-cases represents a fine-grained UOW.
  • We tend to implement these use-cases in the form of wizards, but a simple 'edit' button to indicate the start of the use-case and save/cancel buttons to indicate the end of the use-case are perfectly viable as well.

Thus: Try to recognize the use-cases and represent these as UOWS.

timvw