Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Understanding and Implementing Repository and Unit of Work Pattern in ASP.NET MVC Application

, 12 Apr 2013
In this article we will try to see what is Repository and Unit of Work Pattern in an ASP.NET MVC application.
RepoUowSample-noexe.zip
RepoUowSample
RepoUowSample
App_Data
SampleDatabase.mdf
SampleDatabase_log.LDF
Controllers
Global.asax
Models
SampleDbModel.edmx
Properties
RepoUowSample.csproj.user
Views
BookEn
Books
Home
RepoUowSample.suo
RepoUowSample.zip
SampleDatabase.mdf
SampleDatabase_log.LDF
bin
Content
Global.asax
SampleDbModel.edmx
obj
Debug
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
edmxResourcesToEmbed
Models
TempPE
Models.SampleDbModel.Designer.cs.dll
RepoUowSample.csproj.user
Scripts
RepoUowSample.suo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RepoUowSample.Models;

namespace RepoUowSample.Controllers
{
    public class BooksController : Controller
    {
        private IBooksRepository booksRepository = null;

        public BooksController()
            :this(new BooksRepository())
        {

        }

        public BooksController(IBooksRepository bookRepo)
        {
            this.booksRepository = bookRepo;
        }

        public ActionResult Index()
        {
            List<Book> books = booksRepository.GetAllBooks();
            return View(books);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rahul Rajat Singh
Software Developer (Senior)
India India
I Started my Programming career with C++. Later got a chance to develop Windows Form applications using C#. Currently using C#, ASP.NET & ASP.NET MVC to create Information Systems, e-commerce/e-governance Portals and Data driven websites.

My interests involves Programming, Website development and Learning/Teaching subjects related to Computer Science/Information Systems. IMO, C# is the best programming language and I love working with C# and other Microsoft Technologies.
  • Microsoft Certified Technology Specialist (MCTS): Web Applications Development with Microsoft .NET Framework 4
  • Microsoft Certified Technology Specialist (MCTS): Accessing Data with Microsoft .NET Framework 4
  • Microsoft Certified Technology Specialist (MCTS): Windows Communication Foundation Development with Microsoft .NET Framework 4
 
If you like my articles, please visit my website for more: www.rahulrajatsingh.com[^]
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 12 Apr 2013
Article Copyright 2013 by Rahul Rajat Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid