UnitOfWork and NHibernate in Agathas case study
NHibernate has Unit of Work built in.
In the Agatha's case study, why do you insist on providing a UnitOfWork interface and a NHUnitofWork implementation class? You do not use it, after all!!!
I think, it was a copy and paste from Chapter 7, where you presented a sample UoW implementation using Dictionaries.
But, in the case study, where NHibernate is used, you never need it in your code:
- You never use the repository interface passed as parameter in the NHUnitOfWork class methods (Chapter 11, page 462).
- You pass the UoW as a parameter to the Repository but you never actually use it in the methods! (Chapter 11, page 463,464).
Instead, you always let the NHibernate session do the job, which of course is correct (since Session handles all the UoW implementation, itself):
So, please, fix the sample code and the download files for the case study.