SlideShare a Scribd company logo
Repository and 
Unit of Work 
Design Patterns 
29th October 2014 
Presented By: Hatim Hakeel
10/29/2014 Page 2
Repository 
Object-Relational Metadata Mapping 
Patterns 
• Metadata Mapping 
• Query Object 
• Repository 
Repository – Mediates between the 
domain and data mapping layers using a 
collection-like interface for accessing 
domain objects 
10/29/2014 Page 3
What about DAOs ? 
• A Data Access Object doesn’t hide to the 
Data Access Layer that it is accessing a 
data table, unlike a Repository. 
• A DAO typically has a 1:1 map with a data 
store table or entity-set. 
• A Repository acts at a higher level of 
abstraction working with aggregations of 
business entities. 
10/29/2014 Page 4
Why use Repositories ? 
• Abstraction layer between Business Logic 
Layer and Data Access Layer. 
• Insulates application (Controller) from data 
store changes. 
• Facilitates automated Unit Testing, Test 
Driven Development. How ? 
• Easy to create mock repositories using 
in-memory domain object collections 
as a data store. But it’s difficult to mock 
entities similarly. 
10/29/2014 Page 5
UoW 
Object-Relational Behavior Patterns 
• Unit of Work 
• Identity Map 
• Lazy Load 
UoW – Maintains a list of objects affected 
by a business transaction and 
coordinates the writing out of changes 
and the resolution of concurrency 
problems 
10/29/2014 Page 6
Why use UoW ? 
• Keeps track of manipulated objects in order to 
synchronize in-memory data with the data store. 
• Provides a single transaction for multiple queries. 
• The UoW commits the transaction. 
• If the commit fails, rollback. 
• Single commit call on the database. 
• All object tracking information is centralized. 
• Provides a firm means for complex scenarios like 
handling business transactions that span several 
system transactions using Optimistic Offline 
Lock and Pessimistic Offline Lock. 
10/29/2014 Page 7
Entity Framework 5 and ASP.NET 
MVC 4 
and previous versions… 
• Repository classes with a UoW class. 
• Repository classes without a UoW class. 
• Single Repository. 
• A Repository class per Entity. 
10/29/2014 Page 8
The Overall Bigger Picture 
10/29/2014 Page 9
A possible project structure 
10/29/2014 Page 10
IUnitOfWork interface 
10/29/2014 Page 11
UnitofWork.cs i 
10/29/2014 Page 12
GenericRepository<TEntity> Getters ii 
10/29/2014 Page 13
Persist DbContext changes and clean 
up resources iii 
10/29/2014 Page 14
IGenericRepository<TEntity> 
10/29/2014 Page 15
GenericRepository<TEntity> 
constructor i 
10/29/2014 Page 16
IEnumerable<TEnitity> Get(…) ii 
10/29/2014 Page 17
Remaining CRUD method 
implementations iii 
10/29/2014 Page 18
EF DbContext implementer 
10/29/2014 Page 19
How does the architectural wiring come 
live in the controller ? 
10/29/2014 Page 20
Sample Edit, Get(…) calls 
10/29/2014 Page 21
Entity Framework 6 and ASP.NET 
MVC 5 
From http://goo.gl/eyDbrM 
Advanced Entity Framework 6 Scenarios for an MVC 5 Web Application (12 of 12) | 
ASP.NET MVC Site 
10/29/2014 Page 22
Do we still need Repository and 
UoW ? 
10/29/2014 Page 23
Consider following scenarios 
without repositories 
10/29/2014 Page 24
In Summary 
• Business objects should interface with a 
business oriented storage service 
• Data objects should interface with a data 
oriented service 
• The repository should be the bridging 
mediator 
• BUT the real use case for the Repository 
pattern is in dealing with multiple 
persistence services 
10/29/2014 Page 25
Sample project hosted at GitHub 
https://github.com/hatimhakeel/UniversityVille 
10/29/2014 Page 26
Thank You 
Questions ? 
10/29/2014 Page 27

More Related Content

What's hot

SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
Andreas Enbohm
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Thinking in react
Thinking in reactThinking in react
Thinking in react
aashimadudeja
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
M Ahsan Khan
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
Omri Spector
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - AdapterManoj Kumar
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
Ngrx: Redux in angular
Ngrx: Redux in angularNgrx: Redux in angular
Ngrx: Redux in angular
Saadnoor Salehin
 
Struts
StrutsStruts
Struts
s4al_com
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
Mudasir Qazi
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
Reactjs
Reactjs Reactjs
Reactjs
Neha Sharma
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 

What's hot (20)

SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Thinking in react
Thinking in reactThinking in react
Thinking in react
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Ngrx: Redux in angular
Ngrx: Redux in angularNgrx: Redux in angular
Ngrx: Redux in angular
 
Struts
StrutsStruts
Struts
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Reactjs
Reactjs Reactjs
Reactjs
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 

Viewers also liked

Generic repository pattern with ASP.NET MVC and Entity Framework
Generic repository pattern with ASP.NET MVC and Entity FrameworkGeneric repository pattern with ASP.NET MVC and Entity Framework
Generic repository pattern with ASP.NET MVC and Entity Framework
Md. Mahedee Hasan
 
Introduction the Repository Pattern
Introduction the Repository PatternIntroduction the Repository Pattern
Introduction the Repository Pattern
Bill Lin
 
Dapper performance
Dapper performanceDapper performance
Dapper performance
Suresh Loganatha
 
Repository design pattern in laravel - Samir Poudel
Repository design pattern in laravel - Samir PoudelRepository design pattern in laravel - Samir Poudel
Repository design pattern in laravel - Samir Poudel
Sameer Poudel
 
Dependency injection in asp.net core
Dependency injection in asp.net coreDependency injection in asp.net core
Dependency injection in asp.net core
Bill Lin
 
Generic Unit Of Work Service & Repository
Generic Unit Of Work Service & RepositoryGeneric Unit Of Work Service & Repository
Generic Unit Of Work Service & RepositoryAbdulah Al Bahhar
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
Kirk Bushell
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Svetlin Nakov
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
Lars-Erik Kindblad
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
James Johnson
 
Generic Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkGeneric Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
Real World Dependency Injection - phpday
Real World Dependency Injection - phpdayReal World Dependency Injection - phpday
Real World Dependency Injection - phpdayStephan Hochdörfer
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
 
A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important Features
Julie Lerman
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?
Julie Lerman
 
ASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline InternalsASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline Internals
Lukasz Lysik
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
Umar Ali
 
ASP.NET MVC 4 - Routing Internals
ASP.NET MVC 4 - Routing InternalsASP.NET MVC 4 - Routing Internals
ASP.NET MVC 4 - Routing Internals
Lukasz Lysik
 
Save Repository From Save
Save Repository From SaveSave Repository From Save
Save Repository From Save
Norbert Orzechowicz
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
citizenmatt
 

Viewers also liked (20)

Generic repository pattern with ASP.NET MVC and Entity Framework
Generic repository pattern with ASP.NET MVC and Entity FrameworkGeneric repository pattern with ASP.NET MVC and Entity Framework
Generic repository pattern with ASP.NET MVC and Entity Framework
 
Introduction the Repository Pattern
Introduction the Repository PatternIntroduction the Repository Pattern
Introduction the Repository Pattern
 
Dapper performance
Dapper performanceDapper performance
Dapper performance
 
Repository design pattern in laravel - Samir Poudel
Repository design pattern in laravel - Samir PoudelRepository design pattern in laravel - Samir Poudel
Repository design pattern in laravel - Samir Poudel
 
Dependency injection in asp.net core
Dependency injection in asp.net coreDependency injection in asp.net core
Dependency injection in asp.net core
 
Generic Unit Of Work Service & Repository
Generic Unit Of Work Service & RepositoryGeneric Unit Of Work Service & Repository
Generic Unit Of Work Service & Repository
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
 
ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4ASP.NET MVC and Entity Framework 4
ASP.NET MVC and Entity Framework 4
 
Generic Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkGeneric Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity Framework
 
Real World Dependency Injection - phpday
Real World Dependency Injection - phpdayReal World Dependency Injection - phpday
Real World Dependency Injection - phpday
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important Features
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?
 
ASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline InternalsASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline Internals
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
 
ASP.NET MVC 4 - Routing Internals
ASP.NET MVC 4 - Routing InternalsASP.NET MVC 4 - Routing Internals
ASP.NET MVC 4 - Routing Internals
 
Save Repository From Save
Save Repository From SaveSave Repository From Save
Save Repository From Save
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
 

Similar to Repository and Unit Of Work Design Patterns

Abinitio Experienced resume-Anilkumar
Abinitio Experienced resume-AnilkumarAbinitio Experienced resume-Anilkumar
Abinitio Experienced resume-Anilkumaranilkumar kagitha
 
Java Spring
Java SpringJava Spring
Java Spring
AathikaJava
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
Karen Benoit
 
NBU Flex Container Hardware Overview Presentation
NBU Flex Container Hardware Overview PresentationNBU Flex Container Hardware Overview Presentation
NBU Flex Container Hardware Overview Presentation
pbtest
 
[Webinar] Nuxeo platform 5.8 webinar
[Webinar] Nuxeo platform 5.8 webinar [Webinar] Nuxeo platform 5.8 webinar
[Webinar] Nuxeo platform 5.8 webinar
Nuxeo
 
Nw2008 tips tricks_edw_v10
Nw2008 tips tricks_edw_v10Nw2008 tips tricks_edw_v10
Nw2008 tips tricks_edw_v10
Harsha Gowda B R
 
fundamentals of data warehouse. initial level.
fundamentals of data warehouse. initial level.fundamentals of data warehouse. initial level.
fundamentals of data warehouse. initial level.
JubayerSuhan
 
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid ApplicationsA Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
ajithranabahu
 
Inside atento [sa 302] - (4094)
Inside atento [sa 302] - (4094)Inside atento [sa 302] - (4094)
Inside atento [sa 302] - (4094)
Javier Torrenteras
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
Hybrid Automation Framework Developement
Hybrid Automation Framework DevelopementHybrid Automation Framework Developement
Hybrid Automation Framework DevelopementGlasdon Falcao
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
Fabio Pellegrini
 
MuleSoft Meetup Adelaide 7th April 2021
MuleSoft Meetup Adelaide 7th April 2021MuleSoft Meetup Adelaide 7th April 2021
MuleSoft Meetup Adelaide 7th April 2021
Nicholas Bowman
 
Se training storage grid webscale technical overview
Se training   storage grid webscale technical overviewSe training   storage grid webscale technical overview
Se training storage grid webscale technical overview
solarisyougood
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
Matthias Noback
 
ExtjsPart1
ExtjsPart1ExtjsPart1
ExtjsPart1
Abhinav Goel
 
Latest (storage IO) patterns for cloud-native applications
Latest (storage IO) patterns for cloud-native applications Latest (storage IO) patterns for cloud-native applications
Latest (storage IO) patterns for cloud-native applications
OpenEBS
 
A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp London
Luca Lusso
 
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
NRB
 
Clean sw 3_architecture
Clean sw 3_architectureClean sw 3_architecture
Clean sw 3_architecture
AngelLuisBlasco
 

Similar to Repository and Unit Of Work Design Patterns (20)

Abinitio Experienced resume-Anilkumar
Abinitio Experienced resume-AnilkumarAbinitio Experienced resume-Anilkumar
Abinitio Experienced resume-Anilkumar
 
Java Spring
Java SpringJava Spring
Java Spring
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
NBU Flex Container Hardware Overview Presentation
NBU Flex Container Hardware Overview PresentationNBU Flex Container Hardware Overview Presentation
NBU Flex Container Hardware Overview Presentation
 
[Webinar] Nuxeo platform 5.8 webinar
[Webinar] Nuxeo platform 5.8 webinar [Webinar] Nuxeo platform 5.8 webinar
[Webinar] Nuxeo platform 5.8 webinar
 
Nw2008 tips tricks_edw_v10
Nw2008 tips tricks_edw_v10Nw2008 tips tricks_edw_v10
Nw2008 tips tricks_edw_v10
 
fundamentals of data warehouse. initial level.
fundamentals of data warehouse. initial level.fundamentals of data warehouse. initial level.
fundamentals of data warehouse. initial level.
 
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid ApplicationsA Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
 
Inside atento [sa 302] - (4094)
Inside atento [sa 302] - (4094)Inside atento [sa 302] - (4094)
Inside atento [sa 302] - (4094)
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
 
Hybrid Automation Framework Developement
Hybrid Automation Framework DevelopementHybrid Automation Framework Developement
Hybrid Automation Framework Developement
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
 
MuleSoft Meetup Adelaide 7th April 2021
MuleSoft Meetup Adelaide 7th April 2021MuleSoft Meetup Adelaide 7th April 2021
MuleSoft Meetup Adelaide 7th April 2021
 
Se training storage grid webscale technical overview
Se training   storage grid webscale technical overviewSe training   storage grid webscale technical overview
Se training storage grid webscale technical overview
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
ExtjsPart1
ExtjsPart1ExtjsPart1
ExtjsPart1
 
Latest (storage IO) patterns for cloud-native applications
Latest (storage IO) patterns for cloud-native applications Latest (storage IO) patterns for cloud-native applications
Latest (storage IO) patterns for cloud-native applications
 
A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp London
 
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
 
Clean sw 3_architecture
Clean sw 3_architectureClean sw 3_architecture
Clean sw 3_architecture
 

Recently uploaded

Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 

Recently uploaded (20)

Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 

Repository and Unit Of Work Design Patterns

  • 1. Repository and Unit of Work Design Patterns 29th October 2014 Presented By: Hatim Hakeel
  • 3. Repository Object-Relational Metadata Mapping Patterns • Metadata Mapping • Query Object • Repository Repository – Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects 10/29/2014 Page 3
  • 4. What about DAOs ? • A Data Access Object doesn’t hide to the Data Access Layer that it is accessing a data table, unlike a Repository. • A DAO typically has a 1:1 map with a data store table or entity-set. • A Repository acts at a higher level of abstraction working with aggregations of business entities. 10/29/2014 Page 4
  • 5. Why use Repositories ? • Abstraction layer between Business Logic Layer and Data Access Layer. • Insulates application (Controller) from data store changes. • Facilitates automated Unit Testing, Test Driven Development. How ? • Easy to create mock repositories using in-memory domain object collections as a data store. But it’s difficult to mock entities similarly. 10/29/2014 Page 5
  • 6. UoW Object-Relational Behavior Patterns • Unit of Work • Identity Map • Lazy Load UoW – Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems 10/29/2014 Page 6
  • 7. Why use UoW ? • Keeps track of manipulated objects in order to synchronize in-memory data with the data store. • Provides a single transaction for multiple queries. • The UoW commits the transaction. • If the commit fails, rollback. • Single commit call on the database. • All object tracking information is centralized. • Provides a firm means for complex scenarios like handling business transactions that span several system transactions using Optimistic Offline Lock and Pessimistic Offline Lock. 10/29/2014 Page 7
  • 8. Entity Framework 5 and ASP.NET MVC 4 and previous versions… • Repository classes with a UoW class. • Repository classes without a UoW class. • Single Repository. • A Repository class per Entity. 10/29/2014 Page 8
  • 9. The Overall Bigger Picture 10/29/2014 Page 9
  • 10. A possible project structure 10/29/2014 Page 10
  • 14. Persist DbContext changes and clean up resources iii 10/29/2014 Page 14
  • 17. IEnumerable<TEnitity> Get(…) ii 10/29/2014 Page 17
  • 18. Remaining CRUD method implementations iii 10/29/2014 Page 18
  • 19. EF DbContext implementer 10/29/2014 Page 19
  • 20. How does the architectural wiring come live in the controller ? 10/29/2014 Page 20
  • 21. Sample Edit, Get(…) calls 10/29/2014 Page 21
  • 22. Entity Framework 6 and ASP.NET MVC 5 From http://goo.gl/eyDbrM Advanced Entity Framework 6 Scenarios for an MVC 5 Web Application (12 of 12) | ASP.NET MVC Site 10/29/2014 Page 22
  • 23. Do we still need Repository and UoW ? 10/29/2014 Page 23
  • 24. Consider following scenarios without repositories 10/29/2014 Page 24
  • 25. In Summary • Business objects should interface with a business oriented storage service • Data objects should interface with a data oriented service • The repository should be the bridging mediator • BUT the real use case for the Repository pattern is in dealing with multiple persistence services 10/29/2014 Page 25
  • 26. Sample project hosted at GitHub https://github.com/hatimhakeel/UniversityVille 10/29/2014 Page 26
  • 27. Thank You Questions ? 10/29/2014 Page 27