Thursday 26 August 2021

Repository Pattern

Repository pattern is one of the Data Access Pattern, which is used to access the data from database or other data source. A repository pattern encapsulates the data access so the consumer no longer has to know about the underlying data structure.

Problem that repository pattern solves

  • The controller / UI is tightly coupled with data access layer , if we are using data access from controller / UI.
  • It is difficult to write a test for the controller / UI without side effects
  • Hard to extends entities with domain specific behaviour.

Benefits of repository pattern

  • The consumer is now separated (decoupled) from the data access
  • Easy to write a test without side-effects.
  • Modify and extend entities before they are passed on to the consumer.
  • A sharable abstraction resulting in less duplication of code.
  • Improved maintainability.

No comments:

Post a Comment

Custome Service Class to connect wcf service

  using  System; using  System.ServiceModel; namespace Custom.Service.Client {      // Borrowed from: http://old.iserviceoriented.com/blog/p...