I have been looking at this excellant blog titled "NHibernate and the Unit of Work Pattern" and have a question regarding the best place to use UnitOfWork.Start in a asp.net mvc project.
My SLN is broken down into the following projects:-
MVC project
Repository
NHibernateUnitOfWork
I have an interface:-
public interface INameRepository
...
IList<Name> GetByOrigin(int OriginId)
...
I have a concrete implementation
public class NameRepository : INameRepository
...
public IList<Name> GetByOrigin(int OriginId) {
using (UnitOfWork.Start()) {
var query = session.Linq<...
return query;
}
}
...
My question is do I wrap all my methods inside all my repositories with using(UnitOfWork.Start()) or is there a better approach?
I am using nHibernate, asp.net mvc.