Repository
should not open the data context, the DataContext
should be passed to it, since it should not own it. Suppose you have an operation that needs to be in a transaction and includes several repositories, what would you do?
You need to use the UnitOfWork
template .
In this template, a UoW
(which wraps the DataContext
) is passed to the repository.
In practice , the ProductManager
in the business layer is created by Unit Of Work
.
source share