I have a repositories implemented with unitOfWork pattern and share a context. i have a service layer on top of these repositories. which has multiple services. When ever i instantiate a service class - unitOfWork instance is created.
But many times these services methods call each other and sometimes operate on common session objects. Which causes a problem of the same entity being tracked by multiple contexts or more specifically -
An entity object cannot be referenced by multiple instances of IEntityChangeTracker.
How are you guys keeping managing your context:
Anything like this - http://www.west-wind.com/weblog/posts/2008/Feb/05/Linq-to-SQL-DataContext-Lifetime-Management
Or
i have also read that people are putting their context in HttpContext and using it per http call / per user?
What is the best way to do this?