Universal Repository

we does use frequently repository design pattern in the asp.net mvc.We use them into Controllers and codes classes like IRepository,BaseRepository.This classes is generic classes.Each Repository class(concrete repository) inherited BaseRepository and uses with related Controller.In there Actually directly using Controller class is not true.we should definition BaseController.

Let’s take a look a below class-diagram


If benefits of Universal Repository class is centralize production(new instance)  of concrete repository.Let’s look at the code now

Now let’s look at how to use


i think that was helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.