I have searched a little bit and I am confused.
<a href="http://techbrij.com/generic-repository-unit-of-work-entity-framework-unit-testing-asp-net-mvc" rel="nofollow">First Approach</a> uses a repository and a service for each entity with Autofac. Unit of work class does not have repositories. Therefore, you should create each repository instead of just creating one unit of work class in caller constructor.
<a href="https://codefizzle.wordpress.com/20...ory-and-unit-of-work-patterns-in-asp-net-mvc/" rel="nofollow">Second Approach</a> uses just a generic repository. It uses extension classes instead of using one repository for each entity. Unit of work class has generic repositories.Therefore, you can just create a unit of work class on caller class constructor.
In this approach we use one generic class for repositories but we create a repository object for each entity. If this approach is fine how can I implement it with Autofac ?
<a href="http://coderdiaries.com/2014/02/05/unitofwork-pattern-in-asp-net-mvc-with-autofac/" rel="nofollow">Third Approach</a> uses one generic repository and one object for generic repository with Autofac. It uses generic methods instead of generic class. But generic repository has unit of work class instead of opposite. Is this anti pattern ?
Which approach should I use ?
<a href="http://techbrij.com/generic-repository-unit-of-work-entity-framework-unit-testing-asp-net-mvc" rel="nofollow">First Approach</a> uses a repository and a service for each entity with Autofac. Unit of work class does not have repositories. Therefore, you should create each repository instead of just creating one unit of work class in caller constructor.
Code:
OrderService(IUnitOfWork unitOfWork, IUserRepository userRepository,IOrderRepository orderRepository,IBalanceRepository balanceRepository)
<a href="https://codefizzle.wordpress.com/20...ory-and-unit-of-work-patterns-in-asp-net-mvc/" rel="nofollow">Second Approach</a> uses just a generic repository. It uses extension classes instead of using one repository for each entity. Unit of work class has generic repositories.Therefore, you can just create a unit of work class on caller class constructor.
Code:
OrderService(IUnitOfWork unitOfWork)
In this approach we use one generic class for repositories but we create a repository object for each entity. If this approach is fine how can I implement it with Autofac ?
<a href="http://coderdiaries.com/2014/02/05/unitofwork-pattern-in-asp-net-mvc-with-autofac/" rel="nofollow">Third Approach</a> uses one generic repository and one object for generic repository with Autofac. It uses generic methods instead of generic class. But generic repository has unit of work class instead of opposite. Is this anti pattern ?
Code:
OrderService(IUnitOfWork unitOfWork,IGenericRepository repository)
Which approach should I use ?