Interviews - C# Corner

Ano Mepani
What is purpose of repository pattern or generic repository pattern in entity framework ? What is pros and cons of implementing Generic repository pattern ?
  • Navneet Arora
    May, 2018 23

    As we all know repository pattern uses a generic base class which enables DRY (Don't-Repeat-Yourself) by inheriting from the base class to specialized child classes.Using the repository pattern means you don't want to expose the concrete implementations of your repositories to your other layers.Pros: -Encourages DRY (don't repeat yourself) design in that identical queries are written only once per set of query conditions i.e. CRUD operations -Enables unit testing by allowing itself to be abstracted into an interface -Enables an opportunity for business-level validationCons: -Breaks DRY philosophy in that you're generally repeating your database schema -You need to be very careful while writing a new function as it may be already written. -To make the function reusable you may need to update existing functions, again and again, that may break existing functionality.

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS