SlideShare uma empresa Scribd logo
1 de 17
Object-Relational Mapping and Dependency Injection
Object-Relational Mapping
ORM Concepts
What is ORM?
•   Object Relational Mapping is a technique for converting between
    incompatible type systems in Object Oriented (OO) programming.
•   Primary use is to map between business objects in the application layer and
    a relational database.
•   Also can be used to map from business object models to data transfer
    objects (DTO) or a view model.
ORM Advantages and Disadvantages
• Compared to traditional techniques of exchange between an object-oriented
  language and a relational database, ORM often reduces the amount of code
  that needs to be written.
• Compared to traditional techniques, ORM greatly improves the speed of
  application development.
• ORM tools add complexity in areas where proprietary, or database-specific
  techniques have been highly optimized.
• Most ORM tools do not perform well during bulk deletions of data or joins.
• Stored procedures may have better performance, but are not portable.
• Object-relational impedance mismatch can result if the business object
  model does not closely match the relational data structure.
.NET ORM Tools
•   Entity Framework: http://msdn.microsoft.com/data/ef
•   Telerik OpenAccess: http://www.telerik.com/products/orm.aspx
•   Castle Project: http://www.castleproject.org/
•   AutoMapper: https://github.com/AutoMapper/AutoMapper
Microsoft Entity Framework
Why EF?
What is the Entity Framework (EF)?
• EF is Microsoft’s recommended data access technology for new
  applications.
• EF is an object-relational mapper that enables .NET developers to work with
  relational data using domain-specific objects.
• Supported Databases
   • SQL Server
   • MySQL
   • Oracle
   • Sybase
   • Any other database that provides an ADO.NET data provider
EF Use Patterns
• Database First
• Model First
• Code First
   • Code First Migrations
Inversion of Control and Dependency Injection
What is Inversion of Control (IoC)?
• IoC is an object-oriented programming practice where the object coupling is
  bound at run time by an assembler object and is typically not known at
  compile time using static analysis.
• Inversion of control as a design guideline serves the following purposes:
   • There is a decoupling of the execution of a certain task from
     implementation.
   • Every module can focus on what it is designed for.
   • Modules make no assumptions about what other systems do but rely on
     their contracts.
   • Replacing modules has no side effect on other modules.
What is Dependency Injection (DI)?
• DI is a software design pattern that allows a choice of component to be
  made at run-time rather than compile time.
• The binding of objects in the IoC pattern is accomplished through DI.
• Dependency injection involves at least three elements:
   • A dependent consumer,
   • A declaration of a component's dependencies, defined as interface
      contracts,
   • An injector (usually referred to as a container) that creates instances of
      classes that implement a given dependency interface on request.
Why use IoC and DI?
• Encourages Separation of Concerns
• Facilitates unit testing by allowing mock object with known behaviors to be
  injected
• Promotes loose coupling between application layers, allowing
  implementations to be changed as necessary (i.e. mocks to SQL Server to
  Oracle)
.NET Dependency Injection Frameworks
•   Unity DI Container: http://unity.codeplex.com/
•   Ninject: http://www.ninject.org/
•   StructureMap: http://docs.structuremap.net/
•   Spring.NET: http://www.springframework.net/
Microsoft Unity DI Container
Why Unity?
What is Unity and Why Use It?
• The Unity Application Block (Unity) is a lightweight extensible dependency
  injection container
• Unity is developed and maintained by the Microsoft Patterns and Practices
  team
• Unity is fully configurable using standard .NET config file patterns or through
  code initialization
Recommended Tool Links
• Entity Framework: http://msdn.microsoft.com/data/ef
• Unity DI Container: http://unity.codeplex.com/
Questions and Discussion

Mais conteúdo relacionado

Mais procurados

Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
Amit Bhalla
 
Introduction to Neo4j - a hands-on crash course
Introduction to Neo4j - a hands-on crash courseIntroduction to Neo4j - a hands-on crash course
Introduction to Neo4j - a hands-on crash course
Neo4j
 
Optimizing E-Business Suite Storage Using Oracle Advanced Compression
Optimizing E-Business Suite Storage Using Oracle Advanced CompressionOptimizing E-Business Suite Storage Using Oracle Advanced Compression
Optimizing E-Business Suite Storage Using Oracle Advanced Compression
Andrejs Karpovs
 
Database Consolidation using the Oracle Multitenant Architecture
Database Consolidation using the Oracle Multitenant ArchitectureDatabase Consolidation using the Oracle Multitenant Architecture
Database Consolidation using the Oracle Multitenant Architecture
Pini Dibask
 

Mais procurados (20)

The roadmap for sql server 2019
The roadmap for sql server 2019The roadmap for sql server 2019
The roadmap for sql server 2019
 
Oracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningOracle R12 EBS Performance Tuning
Oracle R12 EBS Performance Tuning
 
Oracle 12c and its pluggable databases
Oracle 12c and its pluggable databasesOracle 12c and its pluggable databases
Oracle 12c and its pluggable databases
 
Database Management System, Lecture-1
Database Management System, Lecture-1Database Management System, Lecture-1
Database Management System, Lecture-1
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
 
New lessons in connection management
New lessons in connection managementNew lessons in connection management
New lessons in connection management
 
Introduction to Neo4j - a hands-on crash course
Introduction to Neo4j - a hands-on crash courseIntroduction to Neo4j - a hands-on crash course
Introduction to Neo4j - a hands-on crash course
 
All of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL DeveloperAll of the Performance Tuning Features in Oracle SQL Developer
All of the Performance Tuning Features in Oracle SQL Developer
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
Cql – cassandra query language
Cql – cassandra query languageCql – cassandra query language
Cql – cassandra query language
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
 
Optimizing E-Business Suite Storage Using Oracle Advanced Compression
Optimizing E-Business Suite Storage Using Oracle Advanced CompressionOptimizing E-Business Suite Storage Using Oracle Advanced Compression
Optimizing E-Business Suite Storage Using Oracle Advanced Compression
 
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
Oracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best PracticesOracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best Practices
 
Database Consolidation using the Oracle Multitenant Architecture
Database Consolidation using the Oracle Multitenant ArchitectureDatabase Consolidation using the Oracle Multitenant Architecture
Database Consolidation using the Oracle Multitenant Architecture
 
Oracle database high availability solutions
Oracle database high availability solutionsOracle database high availability solutions
Oracle database high availability solutions
 
Oracle Database 12c : Multitenant
Oracle Database 12c : MultitenantOracle Database 12c : Multitenant
Oracle Database 12c : Multitenant
 
Chapter 8(designing of documnt databases)no sql for mere mortals
Chapter 8(designing of documnt databases)no sql for mere mortalsChapter 8(designing of documnt databases)no sql for mere mortals
Chapter 8(designing of documnt databases)no sql for mere mortals
 

Destaque

03 Object Relational Mapping
03 Object Relational Mapping03 Object Relational Mapping
03 Object Relational Mapping
Ranjan Kumar
 
좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012
Daum DNA
 
Ling to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysisLing to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysis
Alexander Konduforov
 

Destaque (15)

좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVON좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVON
 
03 Object Relational Mapping
03 Object Relational Mapping03 Object Relational Mapping
03 Object Relational Mapping
 
About Orm.fm
About Orm.fmAbout Orm.fm
About Orm.fm
 
ORM: Object-relational mapping
ORM: Object-relational mappingORM: Object-relational mapping
ORM: Object-relational mapping
 
JDXA, The KISS ORM for Android
JDXA, The KISS ORM for AndroidJDXA, The KISS ORM for Android
JDXA, The KISS ORM for Android
 
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정
 
좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012
 
L16 Object Relational Mapping and NoSQL
L16 Object Relational Mapping and NoSQLL16 Object Relational Mapping and NoSQL
L16 Object Relational Mapping and NoSQL
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
Ling to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysisLing to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysis
 
Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...
 
기술적 변화를 이끌어가기
기술적 변화를 이끌어가기기술적 변화를 이끌어가기
기술적 변화를 이끌어가기
 
SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기
 

Semelhante a Object-Relational Mapping and Dependency Injection

Introduction To Corba
Introduction To CorbaIntroduction To Corba
Introduction To Corba
rajianju
 

Semelhante a Object-Relational Mapping and Dependency Injection (20)

.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
Ef overview
Ef overviewEf overview
Ef overview
 
Viper
ViperViper
Viper
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Spring
SpringSpring
Spring
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
 
Architectural peripherals of react by Vadym Zhiltsov
Architectural peripherals of react by Vadym ZhiltsovArchitectural peripherals of react by Vadym Zhiltsov
Architectural peripherals of react by Vadym Zhiltsov
 
Entity framework introduction sesion-1
Entity framework introduction   sesion-1Entity framework introduction   sesion-1
Entity framework introduction sesion-1
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Introduction To Corba
Introduction To CorbaIntroduction To Corba
Introduction To Corba
 
Java Spring
Java SpringJava Spring
Java Spring
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Stephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edgeStephen Pope - Sitecore on the bleeding edge
Stephen Pope - Sitecore on the bleeding edge
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Transforming to Microservices
Transforming to MicroservicesTransforming to Microservices
Transforming to Microservices
 
IoT-A ARM
IoT-A ARMIoT-A ARM
IoT-A ARM
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Object-Relational Mapping and Dependency Injection

  • 1. Object-Relational Mapping and Dependency Injection
  • 3. What is ORM? • Object Relational Mapping is a technique for converting between incompatible type systems in Object Oriented (OO) programming. • Primary use is to map between business objects in the application layer and a relational database. • Also can be used to map from business object models to data transfer objects (DTO) or a view model.
  • 4. ORM Advantages and Disadvantages • Compared to traditional techniques of exchange between an object-oriented language and a relational database, ORM often reduces the amount of code that needs to be written. • Compared to traditional techniques, ORM greatly improves the speed of application development. • ORM tools add complexity in areas where proprietary, or database-specific techniques have been highly optimized. • Most ORM tools do not perform well during bulk deletions of data or joins. • Stored procedures may have better performance, but are not portable. • Object-relational impedance mismatch can result if the business object model does not closely match the relational data structure.
  • 5. .NET ORM Tools • Entity Framework: http://msdn.microsoft.com/data/ef • Telerik OpenAccess: http://www.telerik.com/products/orm.aspx • Castle Project: http://www.castleproject.org/ • AutoMapper: https://github.com/AutoMapper/AutoMapper
  • 7. What is the Entity Framework (EF)? • EF is Microsoft’s recommended data access technology for new applications. • EF is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. • Supported Databases • SQL Server • MySQL • Oracle • Sybase • Any other database that provides an ADO.NET data provider
  • 8. EF Use Patterns • Database First • Model First • Code First • Code First Migrations
  • 9. Inversion of Control and Dependency Injection
  • 10. What is Inversion of Control (IoC)? • IoC is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time using static analysis. • Inversion of control as a design guideline serves the following purposes: • There is a decoupling of the execution of a certain task from implementation. • Every module can focus on what it is designed for. • Modules make no assumptions about what other systems do but rely on their contracts. • Replacing modules has no side effect on other modules.
  • 11. What is Dependency Injection (DI)? • DI is a software design pattern that allows a choice of component to be made at run-time rather than compile time. • The binding of objects in the IoC pattern is accomplished through DI. • Dependency injection involves at least three elements: • A dependent consumer, • A declaration of a component's dependencies, defined as interface contracts, • An injector (usually referred to as a container) that creates instances of classes that implement a given dependency interface on request.
  • 12. Why use IoC and DI? • Encourages Separation of Concerns • Facilitates unit testing by allowing mock object with known behaviors to be injected • Promotes loose coupling between application layers, allowing implementations to be changed as necessary (i.e. mocks to SQL Server to Oracle)
  • 13. .NET Dependency Injection Frameworks • Unity DI Container: http://unity.codeplex.com/ • Ninject: http://www.ninject.org/ • StructureMap: http://docs.structuremap.net/ • Spring.NET: http://www.springframework.net/
  • 14. Microsoft Unity DI Container Why Unity?
  • 15. What is Unity and Why Use It? • The Unity Application Block (Unity) is a lightweight extensible dependency injection container • Unity is developed and maintained by the Microsoft Patterns and Practices team • Unity is fully configurable using standard .NET config file patterns or through code initialization
  • 16. Recommended Tool Links • Entity Framework: http://msdn.microsoft.com/data/ef • Unity DI Container: http://unity.codeplex.com/

Notas do Editor

  1. .NET ORM tools for databases include EF, NHibernate, TelerikOpenAccess, Castle ActiveRecord.NET Object to Object Mappers include tools like AutoMapper
  2. .NET Implementations: Microsoft Unity, Castle Windsor, StructureMap, Ninject