SlideShare a Scribd company logo
OR Impedance Mismatch
OR Impedance Mismatch

 •Conflicting type systems
 •Conflicting design goals
    Database system focuses specifically on the storage and retrieval of data, whereas an object system
    focuses specifically on the union of state and behavior for easier programmer manipulation
 •Conflicting architectural style
    Most database products are built to assume a fundamentally client/server style of interaction, assuming the
    database is located elsewhere on the network, and programs accessing the database will be doing so via
    some sort of remote access protocol. Object systems assume the precise opposite, and in fact, perform
    significantly worse when distributed.
 •Differing structural relationships
    Relational data stores track entities in terms of relations between tuples and tuplesets; object-oriented
    systems instead prefer to track entities in terms of classes, compilation of state and behavior that relates to
    one another through IS-A and/or HAS-A style unidirectional connections. Where databases use foreign-key
    relationships to indicate relations, objects use references or pointers




                                                                                                                      2
OR Impedance Mismatch

 •Differing identity constructs
    Object systems use an implicit sense of identity to distinguish between objects of similar state (the
    ubiquitous this pointer or reference), yet databases require that sense of identity to be explicit via primary
    key column or columns. In fact, in modern object-oriented languages an object system cannot be built
    without a sense of object identity, whereas relational tables can have no primary key whatsoever, if
    desired.
 •Transactional boundaries
    Object systems do not have any sense of "transactional demarcation" when working with the objects,
    whereas database instances must in order to deal with the multi-user requirements of a modern
                .
    client/server-based system

 •Query/access capabilities
    Retrieving data stored in a relational database makes use of SQL, a declarative language predicated on
    the mathematical theory of relational algebra and predicate. In object systems, the entire object is required
    in order to navigate from one object to the next, meaning that the entire graph of objects is necessary in
    order to find two disparate parts of data—for a system intended to remain entirely in working memory, this
    is of no concern, but for a system whose principal access is intended to be distributed, as relational
    database are, this can be a crippling problem.




                                                                                                                     3
Object Relational Mapping
Wikipedia defines an ORM as: “a programming technique for
converting data between incompatible type systems in
relational databases and object-oriented programming
languages. This creates, in effect, a "virtual object
database," which can be used from within the programming
language.” An ORM has to provide a facility to map
database tables to domain objects, using a design surface or
wizard. This mapping is in-between your database and
domain model, independent from the source code and the
database. The ORM runtime then converts the commands
issued by the domain model against the mapping into back
end database retrieval and SQL statements. Mapping allows
an application to deal seamlessly with several different
database models, or even databases.

                                                          4
The LINQ Project
      C#             VB            Others…


     .NET Language Integrated Query

   Standard
                  DLinq              XLinq
    Query
                (ADO.NET)         (System.Xml)
   Operators


                                    <book>
                                      <title/>
                                      <author/>
                                      <year/>
                                      <price/>
                                    </book>




    Objects    SQL        WinFS        XML
Data Access In APIs Today

   Sql C onnect i on c = new                Queries in
 Sql C onnect i on( …) ;                      quotes
   c. Open( ) ;
   Sql C m
         om and cm = new Sql C m
                      d              om and( Arguments
         @ SELEC c. N e, c. Phone
          "         T      am                  loosely
                  FR M C
                     O ust om s cer             bound
                  W ER c. C t y = @
                    H E        i      p0"
                                               Results
         );
                                               loosely
   cm Par am er s. AddW t hVal ue( " @po" ,
      d.         et            i
                                                typed
                                              Compiler
 " London" ) ;
    at eader dr = c. Execut e( cm ; cannot help
   D aR                                 d)
   w l e ( dr . R
    hi              ead( ) ) {                   catch
         st r i ng nam = dr . G St r i ng( 0) mistakes
                       e          et          ;
Data Access with DLINQ

 publ i c cl ass C  ust omer       Classes
 {                                 describe
      publ i c i nt I d;             data
                                  Tables are
      publ i c st r i ng N e;
                          am
                                  collections
      publ i c st r i ng Phone;
      …
 }
                                    Query is
 Tabl e<C ust om > cust om s =
                er        er      natural part
 db. Cust om s;
            er                       of the
                                   language
                                      The
 var cont act s =                   compiler
     f r om c i n cust om s
                         er        helps you
DLinq For Relational Data
 Accessing data with DLinq
                              Classes
      public class Customer { … }
                               describe data

  public class Northwind: DataContext  Tables are
                     {              like collections
   public Table<Customer> Customers;
                      …            Strongly typed
  Northwind db = new } Northwind(…connection
                                     );
             var contacts =       Integrated
          from c in db.Customersquery syntax
         where c.City == "London"
     select new { c.Name, c.Phone }; typed
                              Strongly
                                    results
Architecture
f r om c i n db. Cust om s
                        er
w e c. C t y == " London"
  her       i                        Application
sel ect
  new { c. N e, c. Phone }
              am


                       LINQ Query      Objects   SubmitChanges()


                                                            Services:
                                   DLinq                    - Change tracking
                                                            - Concurrency control
                                 (ADO.NET)                  - Object identity


                         SQL Query     Rows      SQL or
                                                 Stored
                                                 Procs
sel ect N e, Phone
          am
f r om cust om s
              er
w e ci t y = ' London'
  her
                                      SQLSer
Key Takeaways
 Language integrated data access
   Maps tables and rows to classes and objects
   Builds on ADO.NET and .NET Transactions
 Mapping
   Encoded in attributes
   Relationships map to properties
   Manually authored or tool generated
 Persistence
   Automatic change tracking
   Updates through SQL or stored procedures
 DataContext
   Strongly typed database
Querying For Objects
Key Takeaways
 Language Integrated Query
   Compile-time type checking, IntelliSense

 SQL-like query syntax
   With support for hierarchy and relationships

 Intelligent object loading
   Deferred or immediate


                                                  12
Updating Objects
Key Takeaways
 Auto-generated updates
  Using optimistic concurrency

 Transactions
  Integrates with System.Transactions

 SQL pass-through
  Returning objects from SQL queries


                                        14
DLinq Summary
 Allows access to relational data as objects

 Supports Language Integrated Query

 Works with existing infrastructure

 Unifies programming model for objects,
 relational and XML

                                               15
When to Use LINQ to SQL?
The primary scenario for using LINQ to SQL is when building
applications with a rapid development cycle and a simple
one-to-one object to relational mapping against the Microsoft
SQL Server family of databases. In other words, when
building an application whose object model is structured very
similarly to the existing database structure, or when a
database for the application does not yet exist and there is
no predisposition against creating a database schema that
mirrors the object model




                                                           16
When to Use LINQ to SQL?
   I want to…                                                    LINQ to SQL is
                                                                 applicable

   Use an ORM solution and my database is 1:1 with my object
   model

   Use an ORM solution with inheritance hierarchies that are
   stored in a single table

   Use my own plain CLR classes instead of using generated
   classes or deriving from a base class or implementing an
   interface

   Leverage LINQ as the way I write queries


   Use an ORM but I want something that is very performant and
   where I can optimize performance through stored procedures
   and compiled queries




                                                                                  17

More Related Content

What's hot (20)

PDF
02.adt
Aditya Asmara
 
PPS
Ado.net session04
Niit Care
 
PPT
List moderate
Rajendran
 
PPTX
Big Data & Analytics MapReduce/Hadoop – A programmer’s perspective
EMC
 
PPT
Xml processing-by-asfak
Asfak Mahamud
 
PPS
Ado.net session01
Niit Care
 
PPTX
Unit 3 writable collections
vishal choudhary
 
PPS
Ado.net session07
Niit Care
 
PPT
Sedna XML Database: Query Parser & Optimizing Rewriter
Ivan Shcheklein
 
DOC
Sql server
Puja Gupta
 
PPTX
Summary of "Amazon's Dynamo" for the 2nd nosql summer reading in Tokyo
CLOUDIAN KK
 
PPTX
Triplestore and SPARQL
Lino Valdivia
 
PDF
Apache Hadoop Java API
Adam Kawa
 
PDF
Ds lists
Dzinh Tuong
 
PDF
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Sumant Tambe
 
PPT
XQuery Triggers in Native XML Database Sedna
maria.grineva
 
PDF
Beyond Map/Reduce: Getting Creative With Parallel Processing
Ed Kohlwey
 
PDF
Map/Reduce intro
CARLOS III UNIVERSITY OF MADRID
 
PDF
R Introduction
Sangeetha S
 
PPT
Architecture of Native XML Database Sedna
maria.grineva
 
Ado.net session04
Niit Care
 
List moderate
Rajendran
 
Big Data & Analytics MapReduce/Hadoop – A programmer’s perspective
EMC
 
Xml processing-by-asfak
Asfak Mahamud
 
Ado.net session01
Niit Care
 
Unit 3 writable collections
vishal choudhary
 
Ado.net session07
Niit Care
 
Sedna XML Database: Query Parser & Optimizing Rewriter
Ivan Shcheklein
 
Sql server
Puja Gupta
 
Summary of "Amazon's Dynamo" for the 2nd nosql summer reading in Tokyo
CLOUDIAN KK
 
Triplestore and SPARQL
Lino Valdivia
 
Apache Hadoop Java API
Adam Kawa
 
Ds lists
Dzinh Tuong
 
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Sumant Tambe
 
XQuery Triggers in Native XML Database Sedna
maria.grineva
 
Beyond Map/Reduce: Getting Creative With Parallel Processing
Ed Kohlwey
 
R Introduction
Sangeetha S
 
Architecture of Native XML Database Sedna
maria.grineva
 

Viewers also liked (20)

PDF
Phan ii quytrinhkythuatkhaithacmuvachamsoc
Hung Pham Thai
 
PPT
Progress 4 C Association Workshop Dalat 04122009
Hung Pham Thai
 
PDF
K51.24.05.2009
Hung Pham Thai
 
PDF
Chuong 09 vb
Hung Pham Thai
 
PPT
Technology Integration
guest5b9bf4
 
PDF
SharePoint Jumpstart
Kelly Cebold
 
PPT
Technology In The Classroom
hales4
 
PDF
Tcvn 3769 2004
Hung Pham Thai
 
PDF
Rsn dec2008
Hung Pham Thai
 
PPT
Pres Outline Da Lat En
Hung Pham Thai
 
PPT
ITC Project Toads and Frogs
Kuhnbyah
 
PPT
CHỌN GIỐNG
Hung Pham Thai
 
PPT
The North Country Trail
ncta
 
PPT
Technology In The Classroom
hales4
 
PDF
Pdf Slideshare R
Josh Morgan
 
PPT
earth
Hung Pham Thai
 
PDF
Vegetables. growing asparagus in the home garden
Hung Pham Thai
 
KEY
Blockbuster Everything...
laurengrossling
 
PDF
Excel 2007 bai 2-1
Hung Pham Thai
 
PPT
Hmt Health Claims Brussels 1 December Pw
peterwennstrom
 
Phan ii quytrinhkythuatkhaithacmuvachamsoc
Hung Pham Thai
 
Progress 4 C Association Workshop Dalat 04122009
Hung Pham Thai
 
K51.24.05.2009
Hung Pham Thai
 
Chuong 09 vb
Hung Pham Thai
 
Technology Integration
guest5b9bf4
 
SharePoint Jumpstart
Kelly Cebold
 
Technology In The Classroom
hales4
 
Tcvn 3769 2004
Hung Pham Thai
 
Rsn dec2008
Hung Pham Thai
 
Pres Outline Da Lat En
Hung Pham Thai
 
ITC Project Toads and Frogs
Kuhnbyah
 
CHỌN GIỐNG
Hung Pham Thai
 
The North Country Trail
ncta
 
Technology In The Classroom
hales4
 
Pdf Slideshare R
Josh Morgan
 
Vegetables. growing asparagus in the home garden
Hung Pham Thai
 
Blockbuster Everything...
laurengrossling
 
Excel 2007 bai 2-1
Hung Pham Thai
 
Hmt Health Claims Brussels 1 December Pw
peterwennstrom
 
Ad

Similar to Object Relational Mapping with LINQ To SQL (20)

PPT
L2s 090701234157 Phpapp02
google
 
PPTX
Getting started with entity framework
Lushanthan Sivaneasharajah
 
PPTX
Easy Data Object Relational Mapping Tool
Hasitha Guruge
 
DOC
10265 developing data access solutions with microsoft visual studio 2010
bestip
 
PPT
Getting started with entity framework revised 9 09
manisoft84
 
PPT
Introduction to Linq
Shahriar Hyder
 
PPTX
Entity Framework V1 and V2
ukdpe
 
PPTX
Just entity framework
Marcin Dembowski
 
KEY
Introducing the Entity Framework
LearnNowOnline
 
KEY
Introducing LINQ
LearnNowOnline
 
PDF
My cool new Slideshow!
rommel_gagasa
 
PDF
Asp.Net 3.5 Part 2
asim78
 
PPTX
Data Access Tech Ed India
rsnarayanan
 
PDF
L17 Data Source Layer
Ólafur Andri Ragnarsson
 
PDF
Ado Fundamentals
asim78
 
PPTX
SQL-queries-for-Data-Analysts-Updated.pptx
Ganesh Bhosale
 
PDF
Underlaying Technology of Modern O/R Mapper
kwatch
 
PDF
Flash Camp Chennai - Social network with ORM
RIA RUI Society
 
PPTX
Database Basics
Abdel Moneim Emad
 
L2s 090701234157 Phpapp02
google
 
Getting started with entity framework
Lushanthan Sivaneasharajah
 
Easy Data Object Relational Mapping Tool
Hasitha Guruge
 
10265 developing data access solutions with microsoft visual studio 2010
bestip
 
Getting started with entity framework revised 9 09
manisoft84
 
Introduction to Linq
Shahriar Hyder
 
Entity Framework V1 and V2
ukdpe
 
Just entity framework
Marcin Dembowski
 
Introducing the Entity Framework
LearnNowOnline
 
Introducing LINQ
LearnNowOnline
 
My cool new Slideshow!
rommel_gagasa
 
Asp.Net 3.5 Part 2
asim78
 
Data Access Tech Ed India
rsnarayanan
 
L17 Data Source Layer
Ólafur Andri Ragnarsson
 
Ado Fundamentals
asim78
 
SQL-queries-for-Data-Analysts-Updated.pptx
Ganesh Bhosale
 
Underlaying Technology of Modern O/R Mapper
kwatch
 
Flash Camp Chennai - Social network with ORM
RIA RUI Society
 
Database Basics
Abdel Moneim Emad
 
Ad

More from Shahriar Hyder (8)

PPTX
Effective Communication Skills for Software Engineers
Shahriar Hyder
 
DOCX
A JavaScript Master Class - From the Wows to the WTFs
Shahriar Hyder
 
PPTX
Dependency Inversion Principle
Shahriar Hyder
 
PPTX
Bridge Design Pattern
Shahriar Hyder
 
PPT
Command Design Pattern
Shahriar Hyder
 
PPTX
Taking a Quantum Leap with Html 5 WebSocket
Shahriar Hyder
 
PPTX
Functional Programming Fundamentals
Shahriar Hyder
 
PPT
C# 3.0 Language Innovations
Shahriar Hyder
 
Effective Communication Skills for Software Engineers
Shahriar Hyder
 
A JavaScript Master Class - From the Wows to the WTFs
Shahriar Hyder
 
Dependency Inversion Principle
Shahriar Hyder
 
Bridge Design Pattern
Shahriar Hyder
 
Command Design Pattern
Shahriar Hyder
 
Taking a Quantum Leap with Html 5 WebSocket
Shahriar Hyder
 
Functional Programming Fundamentals
Shahriar Hyder
 
C# 3.0 Language Innovations
Shahriar Hyder
 

Recently uploaded (20)

PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 

Object Relational Mapping with LINQ To SQL

  • 2. OR Impedance Mismatch •Conflicting type systems •Conflicting design goals Database system focuses specifically on the storage and retrieval of data, whereas an object system focuses specifically on the union of state and behavior for easier programmer manipulation •Conflicting architectural style Most database products are built to assume a fundamentally client/server style of interaction, assuming the database is located elsewhere on the network, and programs accessing the database will be doing so via some sort of remote access protocol. Object systems assume the precise opposite, and in fact, perform significantly worse when distributed. •Differing structural relationships Relational data stores track entities in terms of relations between tuples and tuplesets; object-oriented systems instead prefer to track entities in terms of classes, compilation of state and behavior that relates to one another through IS-A and/or HAS-A style unidirectional connections. Where databases use foreign-key relationships to indicate relations, objects use references or pointers 2
  • 3. OR Impedance Mismatch •Differing identity constructs Object systems use an implicit sense of identity to distinguish between objects of similar state (the ubiquitous this pointer or reference), yet databases require that sense of identity to be explicit via primary key column or columns. In fact, in modern object-oriented languages an object system cannot be built without a sense of object identity, whereas relational tables can have no primary key whatsoever, if desired. •Transactional boundaries Object systems do not have any sense of "transactional demarcation" when working with the objects, whereas database instances must in order to deal with the multi-user requirements of a modern . client/server-based system •Query/access capabilities Retrieving data stored in a relational database makes use of SQL, a declarative language predicated on the mathematical theory of relational algebra and predicate. In object systems, the entire object is required in order to navigate from one object to the next, meaning that the entire graph of objects is necessary in order to find two disparate parts of data—for a system intended to remain entirely in working memory, this is of no concern, but for a system whose principal access is intended to be distributed, as relational database are, this can be a crippling problem. 3
  • 4. Object Relational Mapping Wikipedia defines an ORM as: “a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database," which can be used from within the programming language.” An ORM has to provide a facility to map database tables to domain objects, using a design surface or wizard. This mapping is in-between your database and domain model, independent from the source code and the database. The ORM runtime then converts the commands issued by the domain model against the mapping into back end database retrieval and SQL statements. Mapping allows an application to deal seamlessly with several different database models, or even databases. 4
  • 5. The LINQ Project C# VB Others… .NET Language Integrated Query Standard DLinq XLinq Query (ADO.NET) (System.Xml) Operators <book> <title/> <author/> <year/> <price/> </book> Objects SQL WinFS XML
  • 6. Data Access In APIs Today Sql C onnect i on c = new Queries in Sql C onnect i on( …) ; quotes c. Open( ) ; Sql C m om and cm = new Sql C m d om and( Arguments @ SELEC c. N e, c. Phone " T am loosely FR M C O ust om s cer bound W ER c. C t y = @ H E i p0" Results ); loosely cm Par am er s. AddW t hVal ue( " @po" , d. et i typed Compiler " London" ) ; at eader dr = c. Execut e( cm ; cannot help D aR d) w l e ( dr . R hi ead( ) ) { catch st r i ng nam = dr . G St r i ng( 0) mistakes e et ;
  • 7. Data Access with DLINQ publ i c cl ass C ust omer Classes { describe publ i c i nt I d; data Tables are publ i c st r i ng N e; am collections publ i c st r i ng Phone; … } Query is Tabl e<C ust om > cust om s = er er natural part db. Cust om s; er of the language The var cont act s = compiler f r om c i n cust om s er helps you
  • 8. DLinq For Relational Data Accessing data with DLinq Classes public class Customer { … } describe data public class Northwind: DataContext Tables are { like collections public Table<Customer> Customers; … Strongly typed Northwind db = new } Northwind(…connection ); var contacts = Integrated from c in db.Customersquery syntax where c.City == "London" select new { c.Name, c.Phone }; typed Strongly results
  • 9. Architecture f r om c i n db. Cust om s er w e c. C t y == " London" her i Application sel ect new { c. N e, c. Phone } am LINQ Query Objects SubmitChanges() Services: DLinq - Change tracking - Concurrency control (ADO.NET) - Object identity SQL Query Rows SQL or Stored Procs sel ect N e, Phone am f r om cust om s er w e ci t y = ' London' her SQLSer
  • 10. Key Takeaways Language integrated data access Maps tables and rows to classes and objects Builds on ADO.NET and .NET Transactions Mapping Encoded in attributes Relationships map to properties Manually authored or tool generated Persistence Automatic change tracking Updates through SQL or stored procedures DataContext Strongly typed database
  • 12. Key Takeaways Language Integrated Query Compile-time type checking, IntelliSense SQL-like query syntax With support for hierarchy and relationships Intelligent object loading Deferred or immediate 12
  • 14. Key Takeaways Auto-generated updates Using optimistic concurrency Transactions Integrates with System.Transactions SQL pass-through Returning objects from SQL queries 14
  • 15. DLinq Summary Allows access to relational data as objects Supports Language Integrated Query Works with existing infrastructure Unifies programming model for objects, relational and XML 15
  • 16. When to Use LINQ to SQL? The primary scenario for using LINQ to SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases. In other words, when building an application whose object model is structured very similarly to the existing database structure, or when a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model 16
  • 17. When to Use LINQ to SQL? I want to… LINQ to SQL is applicable Use an ORM solution and my database is 1:1 with my object model Use an ORM solution with inheritance hierarchies that are stored in a single table Use my own plain CLR classes instead of using generated classes or deriving from a base class or implementing an interface Leverage LINQ as the way I write queries Use an ORM but I want something that is very performant and where I can optimize performance through stored procedures and compiled queries 17