a repository fundamentally works as a mediator between data access layer and
business logic layer of the application. Generally, it would be troublesome to
execute the data access system specifically to business logic layer, it might
bring about repetitive and redundant code forgetting to information for
comparative substances or it might bring about a code that is difficult to test
or access information from it. To solve these types of issues, and to write an
Interface driven and test driven code to get data, we use Repository Pattern .
repository makes queries to the data source for the data, from there on maps
the information from the data source to a business entity object, at last and
perseveres the adjustments in the business element to the data source. A
repository separates the business logic from the interactions with the
underlying data source or Web service.
The separation has three benefits:
1- Data logic or
Web service access logic becomes centralized.
getting substitution point for the unit tests.
2- It have a
Flexible architecture which can be adapted as the general configuration of
the application development.
Repository pattern in C# allows you to separate data access code from the
rest of the system. This isolation promotes code reuse, minimizes future
modifications to code and also simplifies testing of the controller