Code 52 - a new coding project every week

Show and Tell #1 - Generic Repository Pattern series


When Tugberk sent me the link last night to this series, my curiousity was piqued. The generic repository pattern is something we had used for previous Code52 projects - which had also used Entity Framework as the backing store.

For those who are not familiar with it, a repository is typically defined as (from Edward Hieatt and Rob Mee): a component which "mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects."

Why use the repository pattern?

  • decouple the application logic from the data access logic
  • test the application logic in isolation - swap out the database for an in-memory collections of data.

Anyway, before I go spoiling the content, Tugberk has written a series on this:

  • in the first part, he discusses the pattern and why you should care.
  • in the second part, he explains how you can use this with Entity Framework and MVC3.
  • and to finish, he's released NuGet packages for bringing generic repositories into your apps (and the source is on GitHub).

Lots of detail, lots of code samples. I hope you enjoy it.

About the Author

Tugberk Ugurlu hails from Turkey and juggles university studies with his work as a Programmer and Internet Sales Director. He blogs at and is @tourismgeek on Twitter.


  • If you want to learn more on the repository pattern, Jon Galloway and Jesse Liberty did a screencast on Building a Repository using TDD for their video series "The Full Stack". Check it out.
blog comments powered by Disqus