How do I use the repository pattern in C#?

Learn how to correctly implement the repository pattern in C#.

By Jeremy McPeak
February 21, 2017
Screen from "How do I use the repository pattern in C#?" Screen from "How do I use the repository pattern in C#?" (source: O'Reilly)

Repositories can be employed to segregate applications from the complexities of data access, making code easier to maintain. In this video, Jeremy McPeak starts by explaining the heart of the repository pattern: the CRUD principle. Jeremy then demonstrates variations on this implementation while cautioning against potential pattern violations. Following along in Visual Studio, novice C# developers will learn how to define an interface to implement concrete repository classes, correctly implement repository patterns, and create specialized repositories.

Take your C# skills to the next level with Learning Paths.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Jeremy McPeak is a self-taught programmer who began his career tinkering with websites in 1998. He is the author of Beginning JavaScript, 5th Edition, JavaScript 24-Hour Trainer, and co-author of Professional Ajax, 2nd Edition. He also contributes to Tuts+ Code (, providing articles, video tutorials, and courses on JavaScript, C#, ASP.NET, and PHP. He is currently employed by an oil and gas company, building in-house conventional and web applications.

Post topics: Software Engineering