SlideShare a Scribd company logo
ADO.NET & Data Persistence
Frameworks
Overview
Serialization
ADO.NET
Data Tier Approaches
Persistence Frameworks
Serialization
Overview
Serialization Process
MBV vs MBR
Serialization
What is Serialization?
The ability to persist an object’s state data
to a given location (remote server, file,
memory, etc.)
The ability to read persisted data from a
given location and recreate a new type
based on the preserved stateful values
Plays an important role with ADO.NET and
distributed architectures
Serialization
Serialization Process
My
Object
Some
Storage
Device
New
Object
Formatter
Formatter
File, Memory, Buffer, Socket, etc.
Serialize
Deserialize
XmlSerializer – xml
BinaryFormatter – binary
SoapFormatter - soap
Serialization
Serialization is used by .NET Remoting
and .NET Web Services to send objects
back and forth
The .NET Framework provides 3 built-in
class for serialization:
XmlSerializer
BinaryFormatter
SoapFormatter
Serialization
Serialization in Context
Order
Serialize
Deserialize
Order
Serialize
Deserialize
Process
ReceiptReceipt
Machine A Machine B
<order>
<order>
DB
Save
Serialization
Differences:
XmlSerializer: only serializes public
variables, serializes to standard XML
BinaryFormatter: serializes all variables
(public, private, etc.), serializes to bytes
SoapFormatter: serializes all variables
(public, private, etc.), serializes to SOAP
Demo
Serialization
 Implications:
 BinaryFormatter is the fastest
 XmlSerializer is normally second fastest (depends
on the amount of non-public variables)
 SoapSerializer is normally the slowest
 XmlSerializer should be used for multi-
platform/language clients (used by Web Services)
 BinaryFormatter / SoapFormatter is targeted for
.NET environments
Serialization
How objects are passed
MBV – Marshal by Value
 The caller receives a full copy of the object in its
own application domain
 Object code is executed in the local application
 MBV objects are declared by using the
[Serializable] attribute, or by inheriting from the
ISerializable interface
 [Serializable]
public class MBVClass{…}
OR
public class MBVClass: ISerializable
Serialization
How objects are passed
MBR – Marshal by Reference
 The caller receives a proxy to the remote object
 Object code is executed in the remote
application
 MBR objects are declared by inheriting from
MarshalByRefObject
 public class MBRClass : MarshalByRefObject
Serialization
Visualization
Order Order
1. Request Order
2. Receive Order
Order Order
1. Request Order
2. Receive Order Proxy
3. Request
Calculate
Total
3. Request
Calculate
Total
4. Display Total
5. Calculate Total
4. Send Calculate Request
6. Send Total7. Display Total
MBV
MBR
Machine A Machine B
Serialization
MBV vs MBR demo
ADO.NET
Overview
ADO.NET Classes
XMLDataDocuments
What are the pros and cons of each?
Issues with ADO.NET
ADO.NET
 What is ADO.NET?
 Framework that allows you to interact with local and
remote data stores
 Major overhaul of ADO (few similarities)
 Optimized libraries for SqlServer (+CE), Oracle
 Generic libraries for ODBC, OleDb
 Intrinsic support for Xml
 Focused on both connected and disconnected
systems
ADO.NET
High-Level View
IDbDataAdapter IDbCommand IDataReader
IDbConnection
DB
Client
A managed provider implements
these interfaces to provide access
to a specific type of data store
DataSet
In-Memory Disconnected
ADO.NET
 Object Model
Connection
Transaction
DataAdapter
Command
Parameter
DataReader
DataSet
DataTable
DataRow
DataColumn
Constraint
DataRelation
DataView
Connected Objects Disconnected Objects
ADO.NET
 IDbConnection
 Represents a network connection to a relational
database
 Resource intensive, so connections should be kept
open as little as possible (pass through if possible)
 Connection Pooling is automatically enabled for
.NET IDbConnection implementations
 a connection pool is created based on an exact matching
algorithm that associates the pool with the connection
string
ADO.NET
 IDbCommand
 Represents a SQL statement that is
executed while connected to a data source
 Provides 3 primary means of submitting a
SQL statement:
1. ExecuteNonQuery – nothing returned
2. ExecuteScalar – 1 field returned
3. ExecuteReader – returns IDataReader
implementation
ADO.NET
IDbCommand cont.
Used for standard SQL text and/or stored
procedures
Allows for parameters to be passed in via
an IDataParameter implementation
ADO.NET
IDataReader (Forest Gump)
Provides a means of reading one or more
forward-only streams of result sets
DEMO
ADO.NET
IDbDataAdapter
Acts as a bridge between your database
and the disconnected objects in ADO.NET
Object’s Fill method provides an efficient
way to fetch the results of a query and place
them into a DataSet or DataTable (which
can then be used offline)
Reads cached changes from a DataSet or
DataTable and submits them to the
database
ADO.NET
DataTable
One of the central objects in ADO.NET
Used by DataSet, DataView, etc.
Represents one table of data in-memory
Allows you to:
 Fetch data from a DB and store it in a DataTable
 Disconnect from the DB and work with the
DataTable offline
 Reconnect and synchronize changes
ADO.NET
DataTable cont.
DataTable structure is similar to DB Table
structure:
 DataTable is composed of DataRows
 DataRows are composed of DataColumns
 Constraints can be set on a DataTable
DataTables can also be created and
populated in code (they do note require a
corresponding DB Table)
ADO.NET
DataTable cont.
Can be remoted (allows for both MBV and
MBR)
ADO.NET
DataView
Represents a customized view of a
DataTable
Allows for:
 Sorting
 Filtering
 Editing
 Searching
ADO.NET
DataView cont.
Allows multiple controls to bind to the same
DataTable, but show different data
ADO.NET
DataSet (La Femme Nikita)
Major component of the ADO.NET
architecture
Collection of DataTables
Allows for relationships between tables to
be created via DataRelation
Allows constraints to be set on data
ADO.NET
DataSet cont.
Can read and write data and schema as
XML documents
Can be remoted (allows for both MBV and
MBR)
Strongly-typed DataSets can be generated
 Can access tables and columns by name,
instead of using collection-based methods
 Allows for VS.NET Intellisense
ADO.NET
DataSet cont.
Ability to merge multiple DataSets
Ability to copy DataSets
Uses DiffGram (XML) to load and persist
changes
DEMO
ADO.NET
CommandBuilder
Automatically generates single-table
commands
DEMO
ADO.NET
XmlDataDocument
Solves problem of unsychronized access to
relational / XML data
Example:
 DataSet (relational) writes out XML file
 XmlDocument reads in and manipulates XML
 Two objects dealing with same data in
unsynchronized manner
 Result is a disconnect
ADO.NET
XmlDataDocument cont.
Synchronizes data between XmlDocument
and DataSet
Allows both objects to work on the same set
of data
Allows a single app, using a single set of
data, to harness the power of:
 DataSets (remoting, databinding, DataViews...)
 Xml (XPath, XSL, XSLT…)
ADO.NET
Pros and Cons
Best Practices
ADO.NET
 IDbConnection Best Practices
 Pass through whenever possible
 Use constant connectionstrings
 Use multiple accounts (1 for read access, 1 for
read/write access, etc.)
 Use Windows Authentication
 If stored in config file, encrypt
 Avoid displaying error sensitive error information
 Avoid using OleDbConnection.State
 Use the “using” statement in C#
ADO.NET
IDbCommand Best Practices
Use parameters when possible to avoid
SQL injections
ADO.NET
IDataReader Pros and Cons
Extremely fast performance (better than
DataSet)
Forward-only, read-only
Can only operate in connected mode
Must explicitly close both the IDataReader
and the IDbConnection
Not remotable
ADO.NET
 IDataReader Best Practices
 Use CommandBehavior.CloseConnection and
CommandBehavior.SequentialAccess when
possible
 Use IDataReader.Get[Type]() whenever possible
(performance boost)
 Call IDataReader.Cancel() if you’re done w/ a
DataSet but still have pending data
 Keep connection time to a minimum
 Use for large volumes of data to avoid memory
footprint
ADO.NET
 DataTable / DataSet Pros and Cons
 Both MBV and MBR behavior
 Ability to work with data offline
 Ability to represent the same data in multiple ways
via DataView
 Data bindable
 Decreased performance in comparison w/
IDataReader
 Consumes machine memory
 Developers must be careful when posting changes
in a distributed environment
ADO.NET
 DataSet Best Practices
 Strongly-type when possible
 Use for modifiable data and or data that will be
navigated
 Use for caching of frequently searched items
 Use DataSet.GetChanges() prior to sending across
the wire
 Avoid the use of the DataAdapter.Fill overload that
takes startRecord and maxRecords parameters
 Use MBR behaviour sparingly
ADO.NET
 CommandBuilder Pros / Cons
 Removes the need to manually write code
 Decreased performance, due to the need to hit a
database twice to retrieve schema information
 Decreased performance due to very verbose SQL
statements
 Better to use VS.NET’s built-in code generation
 MS: Use of the CommandBuilder should be limited
to design time or ad-hoc scenarios
ADO.NET
 Performance Matrix
1. IDataReader w/ Get[Type]
2. IDataReader w/ GetOrdinal
3. IDataReader by column name
4. Strongly-Typed DataSet w/ custom code
5. DataSet w/ custom code
6. Strongly-Typed DataSet w/
CommandBuilder
7. DataSet w/ CommandBuilder
ADO.NET
 Issues w/ ADO.NET
 No bulk SQL execution (DataSet batch submissions
aren’t done in bulk)
 No asynchronous calls
 Can’t write to interfaces…must use providers
directly
 Inability to get full SQL from
IDbCommand.CommandText when using params
 No object-relational mapping
 No SQL API
Data Tier Approaches
Overview
Presentation – Data
Presentation – Business – Data
Presentation – Business – Service – Data
Data Tier Approaches
Presentation - Data
Data
Access
Code
Data
Access
Code
DBBus
Logic
Bus
Logic
Data
Access
Code
Data
Access
Code
Bus
Logic
Bus
Logic
Data Tier Approaches
 Presentation – Data
 Often has best performance
 Initially the fastest to write (but often requires the
most code over time)
 Inflexible to change
 Business logic not available
 Results in code duplication (business logic…)
 Error prone (connection strings, closing
connections, etc.)
 Leaves architecture decisions to implementer (i.e.
DataSet, DataReader, etc.)
 Ties presentation layer to returned data format
Data Tier Approaches
Presentation – Data w/ DAL
Data
Access
Layer
Data
Access
Layer
DB
Bus
Logic
Bus
Logic
Bus
Logic
Bus
Logic
Data Tier Approaches
Presentation – Data w/ DAL
Requires less code
Somewhat flexible to change
Business logic not available
Results in code duplication (business
logic…)
Ties presentation layer to returned data
format
Data Tier Approaches
Presentation – Business – Data (3 Tier)
Data
Access
Layer
Data
Access
Layer
DB
Bus
Logic
Layer
Bus
Logic
Layer
Data Tier Approaches
 Presentation – Business – Data
 Much more flexible to change
 Business logic is centralized
 Does not tie presentation layer to returned data
format
 More complex to design and build
 Implicit changes may need to be cascaded through
all layers
 Does not clearly address remoting issues
 Business Logic must still be aware of DA classes
Data Tier Approaches
 Presentation – Business – Service – Data
Data
Access
Layer
Data
Access
Layer
DB
Bus
Logic
Layer
Bus
Logic
Layer
Service
Access
Layer
Service
Access
Layer
Local Local or remote
Data Tier Approaches
 Presentation – Business – Service – Data
 Most flexible to change
 Most scalable (but decreased performance)
 Clearly provides remoting capabilities
 Business Logic does not need to be aware of DA
classes
 Most complex to design and build
 Implicit changes may need to be cascaded through
all layers
Persistence Frameworks
Where do Persistence Frameworks fit
in?
Data
Access
Layer
Data
Access
Layer
DB
Bus
Logic
Layer
Bus
Logic
Layer
Service
Access
Layer
Service
Access
Layer
Map Business Entity
objects to relational data
Provide CRUD operations
Provide object caching
Provide object versioning
Provide for remote
persistence
Map to Business
Objects
Persistence Frameworks
Overview
Persistence Frameworks in Context
Desired Attributes
Sample Architecture
Sample Frameworks
Other Approaches
Questions?
Persistence Frameworks
What is an Object Persistence
Framework?
A persistence layer encapsulates the
behavior needed to make objects persistent,
in other words to read, write, and delete
objects to/from permanent storage
Simplifies life for developers by removing
the need for repetitive coding
Focus is on persistence at the Object level
vs. the Data level
Persistence Frameworks
Persistence Frameworks in Context
Data
Access
Layer
Data
Access
Layer
Service
Access
Layer
Service
Access
Layer
DBWebsiteWebsite
Caching
Service
Caching
Service
Bus
Logic
Layer
Bus
Logic
Layer
Bus
Logic
Layer
Bus
Logic
Layer
Smaller Distributed
Architecture
Client
Server
Persistence Frameworks
Persistence Frameworks in Context
DB
WebsiteWebsite
Larger Distributed
Architecture
Caching
Server
Bus
Logic
Layer
Bus
Logic
Layer
Service
Access
Layer
Service
Access
Layer
Data
Access
Layer
Data
Access
Layer
Caching
Service
Caching
Service
WebsiteWebsite
Bus
Logic
Layer
Bus
Logic
Layer
Bus
Logic
Layer
Bus
Logic
Layer
Web Services Server
Client
Machine
Web
Servers
Persistence Frameworks
 Desired Attributes
 Support for run-time and design-time object
relational mapping
 Built-in logging / tracing
 Object caching
 Object versioning (optimistic and pessimistic
concurrency)
 Support for multiple databases
 Support for multiple persistence types (file,
RDBMS)
Persistence Frameworks
 Desired Attributes
 Support for transactions
 Support for cursors
 Support for lazy-loading
 Support for multiple architectures (local, remote…)
 Built-in security models (object caching
encryption…)
 Support for batch operations
 SQL API
 Configurable performance
 Still provides access to ADO.NET classes
Persistence Frameworks
Sample Architecture
Persistence Frameworks
Current .NET Persistence Frameworks
Open Source
 Sisyphus
 Gentle.NET (DEMO)
 Wilson ORMapper (DEMO)
 Bamboo.Prevelance (DEMO)
 LLBLGen (DEMO)
 Atoms
 OJB.NET
 ObjectSpaces*
Persistence Frameworks
Current .NET Persistence Frameworks
Commercial
 EntityBroker
 DataObjects.NET
 LLBLGen Pro
 .NET N-Tier Generator
 Tier Developer
 ORM.NET
 Objectz.NET
Persistence Frameworks
Other Approaches
Poly Model (.NET Patterns)
Business Object JumpStart (Developing
.NET Enterprise Applications)
Serialize object to DB
Persistence Frameworks
 Caching Considerations
 Allow for both local and remote caching
 Local: Hashtable, MMF, etc.
 Support both serialized and non-serialized
 Remote: .NET Remoting, SQL Server, etc.
 Provide Scavengers (LRU, LILO, Expiration…)
 Provide object encryption
 Provide size maximums
 Provide caching stats (Hits/Misses/Duration)
 Allow for multiple cache instances
Persistence Frameworks
Concurrency Approaches
Optimistic/Pessimistic concurrency
 In code – error prone upon reboot
 VersionManager (Timestamp, GUID, etc.)
 In DB – resource intensive
 Timestamp, GUID, etc.
Summary
Serialization
ADO.NET
Data Tier Approaches
Persistence Frameworks
Resources
 Microsoft Patterns & Practices website
 MS: Designing Data Tier Components and Passing
Data Through Tiers
 MS: .NET Data Access Architecture Guide
 MS: ADO.NET Best Practices
 Martin Fowler: Patterns of Enterprise Application
Architecture
 David Sceppa: ADO.NET
 Clifton Nock: Data Access Patterns
 Sun: Core J2EE Patterns
 Andrew Tobias: C# and the .NET Platform

More Related Content

What's hot

For Beginners - Ado.net
For Beginners - Ado.netFor Beginners - Ado.net
For Beginners - Ado.netTarun Jain
 
ADO.NET
ADO.NETADO.NET
ADO.NET
Wani Zahoor
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
FaRid Adwa
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
iFour Institute - Sustainable Learning
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
Anekwong Yoddumnern
 
Ado.net
Ado.netAdo.net
Ado.net
dina1985vlr
 
Ado.net
Ado.netAdo.net
Ado.net
Vikas Trivedi
 
Ado .net
Ado .netAdo .net
Ado .net
Manish Singh
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
Randy Connolly
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
Snehal Harawande
 
ado.net
ado.netado.net
ado.net
ZAIYAUL HAQUE
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
Umar Ali
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Ado.net
Ado.netAdo.net
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
Umar Farooq
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb netZishan yousaf
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NET
DhruvVekariya3
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
Everywhere
 

What's hot (20)

For Beginners - Ado.net
For Beginners - Ado.netFor Beginners - Ado.net
For Beginners - Ado.net
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado .net
Ado .netAdo .net
Ado .net
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
Ado.net
Ado.netAdo.net
Ado.net
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
 
ado.net
ado.netado.net
ado.net
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NET
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
 

Similar to Ado.net &amp; data persistence frameworks

6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdfguest5eed7
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdfguest5eed7
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...
Ram Murat Sharma
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaSonu Vishwakarma
 
Discover Database
Discover DatabaseDiscover Database
Discover Database
Wayne Weixin
 
Discover database
Discover databaseDiscover database
Discover database
Wayne Weixin
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
Akhil Mittal
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05Niit Care
 
Ado Net
Ado NetAdo Net
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
Michael Heron
 
Ef code first
Ef code firstEf code first
Ef code first
ZealousysDev
 
Is2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_introIs2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_introdannygriff1
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12Sisir Ghosh
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
jmsthakur
 
Ado
AdoAdo

Similar to Ado.net &amp; data persistence frameworks (20)

6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
 
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
6 Slidesdfsdfsdhbkdflgjdflgjlkeroueriotr,Dnghkfxhckghdsflhl;Jkjlahfdhklgfdgdf
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Discover Database
Discover DatabaseDiscover Database
Discover Database
 
Discover database
Discover databaseDiscover database
Discover database
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
 
Ado Net
Ado NetAdo Net
Ado Net
 
7 data management design
7 data management design7 data management design
7 data management design
 
Ado
AdoAdo
Ado
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
Ef code first
Ef code firstEf code first
Ef code first
 
Is2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_introIs2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_intro
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
 
Ado
AdoAdo
Ado
 

More from Luis Goldster

Ruby on rails evaluation
Ruby on rails evaluationRuby on rails evaluation
Ruby on rails evaluation
Luis Goldster
 
Design patterns
Design patternsDesign patterns
Design patterns
Luis Goldster
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
Luis Goldster
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
Luis Goldster
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data mining
Luis Goldster
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data mining
Luis Goldster
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discovery
Luis Goldster
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
Luis Goldster
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
Luis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Luis Goldster
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Luis Goldster
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
Luis Goldster
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
Luis Goldster
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
Luis Goldster
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Luis Goldster
 

More from Luis Goldster (20)

Ruby on rails evaluation
Ruby on rails evaluationRuby on rails evaluation
Ruby on rails evaluation
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data mining
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data mining
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discovery
 
Cache recap
Cache recapCache recap
Cache recap
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
 
Api crash
Api crashApi crash
Api crash
 
Object model
Object modelObject model
Object model
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Abstract class
Abstract classAbstract class
Abstract class
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

Ado.net &amp; data persistence frameworks

  • 1. ADO.NET & Data Persistence Frameworks
  • 4. Serialization What is Serialization? The ability to persist an object’s state data to a given location (remote server, file, memory, etc.) The ability to read persisted data from a given location and recreate a new type based on the preserved stateful values Plays an important role with ADO.NET and distributed architectures
  • 5. Serialization Serialization Process My Object Some Storage Device New Object Formatter Formatter File, Memory, Buffer, Socket, etc. Serialize Deserialize XmlSerializer – xml BinaryFormatter – binary SoapFormatter - soap
  • 6. Serialization Serialization is used by .NET Remoting and .NET Web Services to send objects back and forth The .NET Framework provides 3 built-in class for serialization: XmlSerializer BinaryFormatter SoapFormatter
  • 8. Serialization Differences: XmlSerializer: only serializes public variables, serializes to standard XML BinaryFormatter: serializes all variables (public, private, etc.), serializes to bytes SoapFormatter: serializes all variables (public, private, etc.), serializes to SOAP Demo
  • 9. Serialization  Implications:  BinaryFormatter is the fastest  XmlSerializer is normally second fastest (depends on the amount of non-public variables)  SoapSerializer is normally the slowest  XmlSerializer should be used for multi- platform/language clients (used by Web Services)  BinaryFormatter / SoapFormatter is targeted for .NET environments
  • 10. Serialization How objects are passed MBV – Marshal by Value  The caller receives a full copy of the object in its own application domain  Object code is executed in the local application  MBV objects are declared by using the [Serializable] attribute, or by inheriting from the ISerializable interface  [Serializable] public class MBVClass{…} OR public class MBVClass: ISerializable
  • 11. Serialization How objects are passed MBR – Marshal by Reference  The caller receives a proxy to the remote object  Object code is executed in the remote application  MBR objects are declared by inheriting from MarshalByRefObject  public class MBRClass : MarshalByRefObject
  • 12. Serialization Visualization Order Order 1. Request Order 2. Receive Order Order Order 1. Request Order 2. Receive Order Proxy 3. Request Calculate Total 3. Request Calculate Total 4. Display Total 5. Calculate Total 4. Send Calculate Request 6. Send Total7. Display Total MBV MBR Machine A Machine B
  • 14. ADO.NET Overview ADO.NET Classes XMLDataDocuments What are the pros and cons of each? Issues with ADO.NET
  • 15. ADO.NET  What is ADO.NET?  Framework that allows you to interact with local and remote data stores  Major overhaul of ADO (few similarities)  Optimized libraries for SqlServer (+CE), Oracle  Generic libraries for ODBC, OleDb  Intrinsic support for Xml  Focused on both connected and disconnected systems
  • 16. ADO.NET High-Level View IDbDataAdapter IDbCommand IDataReader IDbConnection DB Client A managed provider implements these interfaces to provide access to a specific type of data store DataSet In-Memory Disconnected
  • 18. ADO.NET  IDbConnection  Represents a network connection to a relational database  Resource intensive, so connections should be kept open as little as possible (pass through if possible)  Connection Pooling is automatically enabled for .NET IDbConnection implementations  a connection pool is created based on an exact matching algorithm that associates the pool with the connection string
  • 19. ADO.NET  IDbCommand  Represents a SQL statement that is executed while connected to a data source  Provides 3 primary means of submitting a SQL statement: 1. ExecuteNonQuery – nothing returned 2. ExecuteScalar – 1 field returned 3. ExecuteReader – returns IDataReader implementation
  • 20. ADO.NET IDbCommand cont. Used for standard SQL text and/or stored procedures Allows for parameters to be passed in via an IDataParameter implementation
  • 21. ADO.NET IDataReader (Forest Gump) Provides a means of reading one or more forward-only streams of result sets DEMO
  • 22. ADO.NET IDbDataAdapter Acts as a bridge between your database and the disconnected objects in ADO.NET Object’s Fill method provides an efficient way to fetch the results of a query and place them into a DataSet or DataTable (which can then be used offline) Reads cached changes from a DataSet or DataTable and submits them to the database
  • 23. ADO.NET DataTable One of the central objects in ADO.NET Used by DataSet, DataView, etc. Represents one table of data in-memory Allows you to:  Fetch data from a DB and store it in a DataTable  Disconnect from the DB and work with the DataTable offline  Reconnect and synchronize changes
  • 24. ADO.NET DataTable cont. DataTable structure is similar to DB Table structure:  DataTable is composed of DataRows  DataRows are composed of DataColumns  Constraints can be set on a DataTable DataTables can also be created and populated in code (they do note require a corresponding DB Table)
  • 25. ADO.NET DataTable cont. Can be remoted (allows for both MBV and MBR)
  • 26. ADO.NET DataView Represents a customized view of a DataTable Allows for:  Sorting  Filtering  Editing  Searching
  • 27. ADO.NET DataView cont. Allows multiple controls to bind to the same DataTable, but show different data
  • 28. ADO.NET DataSet (La Femme Nikita) Major component of the ADO.NET architecture Collection of DataTables Allows for relationships between tables to be created via DataRelation Allows constraints to be set on data
  • 29. ADO.NET DataSet cont. Can read and write data and schema as XML documents Can be remoted (allows for both MBV and MBR) Strongly-typed DataSets can be generated  Can access tables and columns by name, instead of using collection-based methods  Allows for VS.NET Intellisense
  • 30. ADO.NET DataSet cont. Ability to merge multiple DataSets Ability to copy DataSets Uses DiffGram (XML) to load and persist changes DEMO
  • 32. ADO.NET XmlDataDocument Solves problem of unsychronized access to relational / XML data Example:  DataSet (relational) writes out XML file  XmlDocument reads in and manipulates XML  Two objects dealing with same data in unsynchronized manner  Result is a disconnect
  • 33. ADO.NET XmlDataDocument cont. Synchronizes data between XmlDocument and DataSet Allows both objects to work on the same set of data Allows a single app, using a single set of data, to harness the power of:  DataSets (remoting, databinding, DataViews...)  Xml (XPath, XSL, XSLT…)
  • 35. ADO.NET  IDbConnection Best Practices  Pass through whenever possible  Use constant connectionstrings  Use multiple accounts (1 for read access, 1 for read/write access, etc.)  Use Windows Authentication  If stored in config file, encrypt  Avoid displaying error sensitive error information  Avoid using OleDbConnection.State  Use the “using” statement in C#
  • 36. ADO.NET IDbCommand Best Practices Use parameters when possible to avoid SQL injections
  • 37. ADO.NET IDataReader Pros and Cons Extremely fast performance (better than DataSet) Forward-only, read-only Can only operate in connected mode Must explicitly close both the IDataReader and the IDbConnection Not remotable
  • 38. ADO.NET  IDataReader Best Practices  Use CommandBehavior.CloseConnection and CommandBehavior.SequentialAccess when possible  Use IDataReader.Get[Type]() whenever possible (performance boost)  Call IDataReader.Cancel() if you’re done w/ a DataSet but still have pending data  Keep connection time to a minimum  Use for large volumes of data to avoid memory footprint
  • 39. ADO.NET  DataTable / DataSet Pros and Cons  Both MBV and MBR behavior  Ability to work with data offline  Ability to represent the same data in multiple ways via DataView  Data bindable  Decreased performance in comparison w/ IDataReader  Consumes machine memory  Developers must be careful when posting changes in a distributed environment
  • 40. ADO.NET  DataSet Best Practices  Strongly-type when possible  Use for modifiable data and or data that will be navigated  Use for caching of frequently searched items  Use DataSet.GetChanges() prior to sending across the wire  Avoid the use of the DataAdapter.Fill overload that takes startRecord and maxRecords parameters  Use MBR behaviour sparingly
  • 41. ADO.NET  CommandBuilder Pros / Cons  Removes the need to manually write code  Decreased performance, due to the need to hit a database twice to retrieve schema information  Decreased performance due to very verbose SQL statements  Better to use VS.NET’s built-in code generation  MS: Use of the CommandBuilder should be limited to design time or ad-hoc scenarios
  • 42. ADO.NET  Performance Matrix 1. IDataReader w/ Get[Type] 2. IDataReader w/ GetOrdinal 3. IDataReader by column name 4. Strongly-Typed DataSet w/ custom code 5. DataSet w/ custom code 6. Strongly-Typed DataSet w/ CommandBuilder 7. DataSet w/ CommandBuilder
  • 43. ADO.NET  Issues w/ ADO.NET  No bulk SQL execution (DataSet batch submissions aren’t done in bulk)  No asynchronous calls  Can’t write to interfaces…must use providers directly  Inability to get full SQL from IDbCommand.CommandText when using params  No object-relational mapping  No SQL API
  • 44. Data Tier Approaches Overview Presentation – Data Presentation – Business – Data Presentation – Business – Service – Data
  • 45. Data Tier Approaches Presentation - Data Data Access Code Data Access Code DBBus Logic Bus Logic Data Access Code Data Access Code Bus Logic Bus Logic
  • 46. Data Tier Approaches  Presentation – Data  Often has best performance  Initially the fastest to write (but often requires the most code over time)  Inflexible to change  Business logic not available  Results in code duplication (business logic…)  Error prone (connection strings, closing connections, etc.)  Leaves architecture decisions to implementer (i.e. DataSet, DataReader, etc.)  Ties presentation layer to returned data format
  • 47. Data Tier Approaches Presentation – Data w/ DAL Data Access Layer Data Access Layer DB Bus Logic Bus Logic Bus Logic Bus Logic
  • 48. Data Tier Approaches Presentation – Data w/ DAL Requires less code Somewhat flexible to change Business logic not available Results in code duplication (business logic…) Ties presentation layer to returned data format
  • 49. Data Tier Approaches Presentation – Business – Data (3 Tier) Data Access Layer Data Access Layer DB Bus Logic Layer Bus Logic Layer
  • 50. Data Tier Approaches  Presentation – Business – Data  Much more flexible to change  Business logic is centralized  Does not tie presentation layer to returned data format  More complex to design and build  Implicit changes may need to be cascaded through all layers  Does not clearly address remoting issues  Business Logic must still be aware of DA classes
  • 51. Data Tier Approaches  Presentation – Business – Service – Data Data Access Layer Data Access Layer DB Bus Logic Layer Bus Logic Layer Service Access Layer Service Access Layer Local Local or remote
  • 52. Data Tier Approaches  Presentation – Business – Service – Data  Most flexible to change  Most scalable (but decreased performance)  Clearly provides remoting capabilities  Business Logic does not need to be aware of DA classes  Most complex to design and build  Implicit changes may need to be cascaded through all layers
  • 53. Persistence Frameworks Where do Persistence Frameworks fit in? Data Access Layer Data Access Layer DB Bus Logic Layer Bus Logic Layer Service Access Layer Service Access Layer Map Business Entity objects to relational data Provide CRUD operations Provide object caching Provide object versioning Provide for remote persistence Map to Business Objects
  • 54. Persistence Frameworks Overview Persistence Frameworks in Context Desired Attributes Sample Architecture Sample Frameworks Other Approaches Questions?
  • 55. Persistence Frameworks What is an Object Persistence Framework? A persistence layer encapsulates the behavior needed to make objects persistent, in other words to read, write, and delete objects to/from permanent storage Simplifies life for developers by removing the need for repetitive coding Focus is on persistence at the Object level vs. the Data level
  • 56. Persistence Frameworks Persistence Frameworks in Context Data Access Layer Data Access Layer Service Access Layer Service Access Layer DBWebsiteWebsite Caching Service Caching Service Bus Logic Layer Bus Logic Layer Bus Logic Layer Bus Logic Layer Smaller Distributed Architecture Client Server
  • 57. Persistence Frameworks Persistence Frameworks in Context DB WebsiteWebsite Larger Distributed Architecture Caching Server Bus Logic Layer Bus Logic Layer Service Access Layer Service Access Layer Data Access Layer Data Access Layer Caching Service Caching Service WebsiteWebsite Bus Logic Layer Bus Logic Layer Bus Logic Layer Bus Logic Layer Web Services Server Client Machine Web Servers
  • 58. Persistence Frameworks  Desired Attributes  Support for run-time and design-time object relational mapping  Built-in logging / tracing  Object caching  Object versioning (optimistic and pessimistic concurrency)  Support for multiple databases  Support for multiple persistence types (file, RDBMS)
  • 59. Persistence Frameworks  Desired Attributes  Support for transactions  Support for cursors  Support for lazy-loading  Support for multiple architectures (local, remote…)  Built-in security models (object caching encryption…)  Support for batch operations  SQL API  Configurable performance  Still provides access to ADO.NET classes
  • 61. Persistence Frameworks Current .NET Persistence Frameworks Open Source  Sisyphus  Gentle.NET (DEMO)  Wilson ORMapper (DEMO)  Bamboo.Prevelance (DEMO)  LLBLGen (DEMO)  Atoms  OJB.NET  ObjectSpaces*
  • 62. Persistence Frameworks Current .NET Persistence Frameworks Commercial  EntityBroker  DataObjects.NET  LLBLGen Pro  .NET N-Tier Generator  Tier Developer  ORM.NET  Objectz.NET
  • 63. Persistence Frameworks Other Approaches Poly Model (.NET Patterns) Business Object JumpStart (Developing .NET Enterprise Applications) Serialize object to DB
  • 64. Persistence Frameworks  Caching Considerations  Allow for both local and remote caching  Local: Hashtable, MMF, etc.  Support both serialized and non-serialized  Remote: .NET Remoting, SQL Server, etc.  Provide Scavengers (LRU, LILO, Expiration…)  Provide object encryption  Provide size maximums  Provide caching stats (Hits/Misses/Duration)  Allow for multiple cache instances
  • 65. Persistence Frameworks Concurrency Approaches Optimistic/Pessimistic concurrency  In code – error prone upon reboot  VersionManager (Timestamp, GUID, etc.)  In DB – resource intensive  Timestamp, GUID, etc.
  • 67. Resources  Microsoft Patterns & Practices website  MS: Designing Data Tier Components and Passing Data Through Tiers  MS: .NET Data Access Architecture Guide  MS: ADO.NET Best Practices  Martin Fowler: Patterns of Enterprise Application Architecture  David Sceppa: ADO.NET  Clifton Nock: Data Access Patterns  Sun: Core J2EE Patterns  Andrew Tobias: C# and the .NET Platform