What is the Difference between Repository and Service Layer in ASP.NET MVC?

Published on May 23, 2013 by admin

Filed under ASP.NET

Last modified May 23, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 3 (3 votes)

This article have been viewed 19825 times

Repository pattern, Unit of Work and Service Layer is one of the most commonly used word or technique especially when you are working on the ASP.NET MVC project.

What is the Difference between Repository and Service Layer in ASP.NET MVC?

These are the common Design pattern terms used in the ASP.NET MVC project.

The Repository is a layer that provides additional abstraction on the data access class in your project.

For example, you can define a Repository interface which has the common methods like Add, Delete, Get, Get All etc. as shown below.

public interface IRepository<T>


IQueryable<T> GetAll();

bool Add(T itemToAdd);

bool Delete(int ItemId);

T Get(int ItemId);


In the other hand, the service layer uses the repository layer and in turn includes and exposes additional business logic. Very simple. Isn’t it?


  1. Interesting .NET Links – May 28 , 2013 | TechBlog
    July 2, 2014 - 9:55 pm

  2. Interesting .NET Links – May 24 , 2013 | TechBlog
    September 28, 2014 - 6:02 pm

Leave a Comment


You might be Interested in these Posts

How to read connection string from web.config in ASP.NET and C# ?

Here's a sample code snippet demonstrating how to get the connection string from your ASP.NET web.co...

How to return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...