Hi,
I've read the Gabriel Schenker's blog posts on the Unit of Work
pattern for NHib and have a few questions.
1. In some repository implementations I see:
public void Add(Entity entity)
{
using (var session = GetSession())
using (var transaction =
session.BeginTransaction())
{
GetSession().Save(entity);
transaction.Commit();
}
}
Now if I open a transaction in my unit of work in some higher layer,
when a transaction is created in the repository, will it be a child
transaction of the previously created one? That is to say, I may want
to do somewhere higher up in my code:
transaction.BeginTransaction()
customerRepository.Add(customer);
orderRepository.Add(order);
transaction.Commit()
I want to make sure that if there is an error saving the order to the
DB, the customer changes will get rolled back. Is this the case?
2. How do people usually reference the Unit of Work in a DDD scenario.
I have defined the Unit of Work in my data layer, but don't want my
domain or service layer with a dependency on my data layer. For
repositories I define their interfaces in the Domain. Would you
recommend a similar approach for the Unit of Work? A Unit of Work
doesn't really seem a domain concept to me, but I'm not sure where
else to put it if I don't want a dependency on my Data layer. (Sorry
if this isn't specifically NHib talk and is more DDD.)
Thanks for feedback.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---