First, thank you.  I think there should be more sharing of UoW
implementations.  I myself am guilty of not sharing the one we've
developed.

Now, on to the opinion!

I don't like the generic repository implementation (IRepository,
AbstractRepository).  As I understand DDD, the repository should speak
the semantics of your domain.  Sometimes my repositories do end up
with simple CRUD-like contracts like you have in yours, but often they
have richer domain semantics (e.g. instead of GetAccount(accountId)
it's GetAtciveAccountForUser(userId) where the repository internally
knows how to query).

That said, out UnitOfWork implementation exposes a generic, NHibernate-
independent contract relying on LINQ.  We have one single
implementation that leverages NHibernate and NHibernate LINQ inside.
It's contract also exposes IQueryable's so it's possible to unit test
the repositories' querying logic.  Here's the methods out UnitOfWork
interface exposes:

  T GetById<T,TId>(TId id);
  IQueryable<T> Find<T>();
  void Save<T>(T entity) ;
  void Delete<T>(T entity);
  void Commit();
  void Abort();

So our UnitOfWork is a constructor parameter to each of our
repositories.  Those repositories in turn use the generic querying/
updating methods on UnitOfWork to actually do the persistence work.

Meanwhile our UnitOfWorkFactory deals with the creation of units of
work and knowing which is the current (we also don't support nesting,
but make the contract capable of supporting it in the future).

Regards,
Brian.

On Jul 12, 7:51 am, Stefan Sedich <[email protected]> wrote:
> Hi,
>
> I have created a UnitOfWork implementation, I wanted something simple for my
> MVC apps, and do not need anything like nested UoW etc.
>
> I have it on 
> GitHubhttp://github.com/stefansedich/YetAnotherUtilsLib/tree/master/src/Yet...
> if
> someone would care to give me some thoughts.
>
> Thanks
> Stefan
>
> --
> Stefan Sedich
> Software Developerhttp://weblogs.asp.net/stefansedich

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to