I would recommend rolling similar repositories into one service. So if you're creating an e-Commerce application roll up ProductRepository, CategoryRepository etc into something like CatalogService and have it host all repositories that are related.
1 +1. In general this leaves you with services that are broken up on business, not entity, lines. – TheDeeno Mar 22 '09 at 14:49 1 So what happens when the Catalog Service uses the ProductRepo to update a product and and the CategoryRepo to update a category in one service method?
Does that mean the ProductRepo changes are done in one transaction and the CategoryRepo changes are done in another transaction? I always thought that repo operations were discrete unless you allow the ProductRepo to change categories as well. What do people do in the real world?
– IanT8 Mar 10 '10 at 20:43.
One option is to provide the ProductService class an instance of CategoryService. Public class ProductService { ICategoryService _categoryService = null; public ProductService(ICategoryService categoryService) { _categoryService = categoryService; } } You could then access the category listings from the ProductService without having to establish a direct coupling to any specific CategoryService implementation.
First of all, as suggested by some answer, EF itself is a repository pattern, there is no need to create further abstraction just to name it as repository. Mockable Repository for Unit Tests, do we really need it? We let EF communicate to test DB in unit tests to test our business logic straight against SQL test DB.
I don't see any benefit of having mock of any repository pattern at all. What is really wrong doing unit tests against test database? Do you want to create repository just so that in future you can easily replace EF with NHbibernate etc or anything else?
Sounds great plan, but is it really cost effective? Linq kills unit tests?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.