views:

1175

answers:

1

I have read in Patterns of Enterprise Application Architecture that a Unit Of Work should only be used in a single Session. So each session should have its only Unit Of Work. Can anybody tell me why I could not use one Unit Of Work for the whole application (in my case ASP.NET).

thx, Lieven Cardoen aka Johlero

+2  A: 

Half of the unit of work pattern is to keep track of changes in a transaction and you could certainly track that for an entire application (this seems to be pretty common) but the other half is the resolution of concurrency problems which becomes meaningless if you are applying the pattern to the entire application rather than on a per session level.
Also, at some point you have to decide "Hey this is a unit...time to commit" and that might be difficult when taking the whole application into account with different users doing different things at the same time.

Ichorus
Well, for now this answer is satisfying, but maybe I'll post another question and explain a little bit my problem. Thx.
Lieven Cardoen