dicon Download source code 7.86 MB

What does Repository mean?
Dictionary meaning: A place where things may be put for safekeeping.

Repository Pattern:
The Repository Pattern allows to centralise all data access logic in one place. It is a common construct to avoid duplication of data access logic throughout our application. The Repository pattern adds a separation layer between the data and business layers of an application.

IC340233

Generic Repository Pattern:
A generic(relating to) repository is often used with the ORM(entity framework) to speed up the process of creating a data layer.With generic feature, we can reduce the amount of code we need for common scenarios.

Explanation:
interface IRepository
Show an interface of a generic repository of type T, which is a LINQ to SQL entity. It provides a basic interface with operations like Insert, Update, Delete, GetById and GetAll.

IDisposable
The IDisposable Interface, Provides a mechanism for releasing unmanaged resources.

where T : class

This is constraining the generic parameter to a class. Click for more
The type argument must be a reference type; this applies also to any class, interface, delegate, or array type.

Use of Generic Repository in  MVC-Application:

Explanation:

Declaration of GenericRepository reference.

In the constructor we initialize the object with GenericRepository class, passing Customer_Entities objct to the constructor as parameter 

Hope this will help 🙂

8 Comments

Leave a Reply

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