how to implement the repository pattern in an asp.net mvc application dhananjay kumar developer...

11
How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist – Infragistics Microsoft MVP http :// debugmode.net

Upload: laurence-holland

Post on 18-Jan-2018

226 views

Category:

Documents


0 download

DESCRIPTION

Share your experience by tweeting and Facebook with hashtag #Infragistics or mention

TRANSCRIPT

Page 1: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

How to implement the Repository Pattern in an ASP.NET MVC Application

Dhananjay KumarDeveloper Evangelist – Infragistics Microsoft MVP http://debugmode.net

Page 2: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Some Information Webinar recording will be available on http://

www.infragistics.com/community/blogs/dhananjay_kumar/default.aspx

Visit http://www.infragistics.com/ for all the products details.

Tweet us @infragistics for your experience

Please reach out to us at [email protected] for any follow up questions you may have. We welcome the opportunity to assist you.

Page 3: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Share your experience by tweeting and Facebook with hashtag #Infragistics or mention to @infragistics

Page 4: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Host : Dhananjay Kumar

Developer Evangelist – Infragistics

6 times Microsoft MVP @debug_mode

Blog : http://debugmode.net

Email : [email protected]

Page 5: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Agenda• What is Repository Pattern • Advantages of Repository Pattern• Step by Step implementing Repository

pattern • Creating Core Project • Creating Infrastructure Project • Creating Test Project • Creating MVC Project

Page 6: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Advantage of Repository Pattern

Business logic can be unit tested without data access logic

Database access code can be reused

Database access code is centrally managed so easy to implement any database access policies such that caching

Easy to implement domain logics

Domain entities or business entities are strongly typed with the annotations

Page 7: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Some of the difficulties Duplicate code

Difficulty implementing any data related logic or policies such that caching

Difficulty in unit testing the business logic without having the data access layer

Tightly coupled business logic and database access logic

Page 8: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Project Structure

Page 9: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Project Structure Project Responsibility Type

Core Project Domain entities and interface for database operations

Class library

Infrastructure Project Libraries to perform database operations. Such as Entity Framework library.

Class library

Test Project Unit Tests for Infrastructure projects

Unit Test

MVC Project MVC based web application using Infrastructure and Core projects libraries using Dependency Injection

MVC

Page 10: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

Let us write Code step by step to implement Repository Pattern

Page 11: How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist  Infragistics Microsoft MVP

What Infragistics can offer you?• We welcome all of you to take advantage of a FREE 30 Day Trial by downloading

the product at: http://www.infragistics.com/products/ultimate/download

• Please reach out to us at [email protected] for any follow up questions you may have. We welcome the opportunity to assist you.