c# - Unit of work, repository, context -


if take at question have question on next step.

imagine have 2 repositories generating items , subitems. have unitofwork acts context changes (in simple case) 2 different items.

there seem few ways of generating unitofwork, injected repository, can generated factory (and either injected or retrieved factory.

my question how unitofwork notify repositories changes committed?

i guess can have repository subscribe events on unitofwork commit/rollback.

second question, idea of unit of work is, if have right, co-ordinate updates may conflict. using example of item , subitem (an item has number of subitems) unitofwork coordinates item written first allowing subitem written? seem need unit of work know repositories seems wrong.

thanks.

the way structured repository have unitofwork "token", spawned beginunitofwork() method on repo, had passed pretty other method on repo made db calls. thing has know how do, conceptually, disposed, when happens causes nhibernate session associated uow closed. being given delegate protected method in repo called in dispose method. me abstract actual data-access mechanism; can implement same pattern regardless of end, , users of pattern cannot hack unitofwork @ actual data-access mechanism.

ymmv; require classes need perform db objects dependent on repository unit of work. use additional delegates expose methods on unitofwork allow dependency.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -