DAT430 Extending Microsoft ® ADO.NET Building a Custom Data Factory API DAT430 Extending Microsoft ® ADO.NET Building a Custom Data Factory API Gert E.R.

Slides:



Advertisements
Similar presentations
1 Interface IDbConnection ConnectionString defines data base connection Open and close connection Properties of connection object Creates Command-Object.
Advertisements

Tiger Computer Services Ltd Using Interfaces in.NET Simplifying access to multiple DB providers in.NET Liam
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
1 ADO.NET. 2.NET Framework Data Namespaces System.Data –Base set of classes and interfaces for ADO.NET System.Data.Common –Classes shared by the.NET Data.
ADO. NET. What is “ADO.Net”? ADO.Net is a new object model for dealing with databases in.Net. Although some of the concepts are similar to the classical.
.Net Overview Data Driven Desktop and Web Applications using VB.Net and ASP.Net, C#.Net or J#.Net.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Programming in ADO.NET: Data-Centric Applications and ADO.NET Original copyright by Microsoft, 2002, with minor modifications by Dan Eaves, 2005.
Objective In this session we will discuss about : What is ADO. NET ?
Leveraging Application Blocks in Your Application Development Ihsan Anabtawi Technology Specialist Microsoft ® Corporation.
C# programming with database Basic guideline. First step Install SQL Server 2008/2010 (Professional edition if possible) Install Visual Studio 2008/2010.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
Visual Studio ®.NET Data with XML Carlotta Eaton ( Associate Professor of IST New River Community College Slides by Microsoft Modified.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
Accessing SQL Server and OLE DB from.NET Svetlin Nakov Telerik Corporation
CIS 375—Web App Dev II ASP.NET 10 Database 2. 2 Introduction to Server-Side Data Server-side data access is unique in that Web pages are basically ___________.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
Introduction to Database Development Using Borland Data Providers 2128 Martin Rudy.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
Module 2: Connecting to Data Sources. Overview Choosing a.NET Data Provider Defining a Connection Managing a Connection Handling Connection Exceptions.
Module 7: Accessing Data by Using ADO.NET
DAT 360: DTS in SQL Server 2000 Best Practices Euan Garden Group Manager, SQL Server Microsoft Corporation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
Module 3: Performing Connected Database Operations.
ADO.NET connections1 Connecting to SQL Server and Oracle.
1 11/10/05CS360 Windows Programming ADO.NET. 2 11/10/05CS360 Windows Programming ADO.NET  Behind every great application is a database manager o Amazon.
DAT 332 SQL Server 2000 Data Transformation Services (DTS) Best Practices Euan Garden Product Unit Manager SQL Server Development Microsoft Corporation.
The Problems HTTP is disconnected So many database vendors Create a simple consistent versatile interface on the data Look at ADO.NET classes OleDb SQL.
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
Accessing Data with Microsoft Visual C# Applications.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
HNDIT Rapid Application Development
Module 4 Introduction ADO.NET.
1 Database Programming with ADO.NET Kashef Mughal.
Presented by Syed Baber Development Lead Mazik Global.
C# .NET Software Development
DEV332 Programming for the Middle Tier in Visual Basic.NET Billy Hollis Author / Consultant.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Session 8: Data Management (with Stored Procedures)
1 Introduction to Web Application Review. 2 Five Layers Architecture HTML, CSS, Java Script ASP.net User ’ s.dll, Nunit, Web Services ADO.net SQL Server,
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 The SqlCommand Object ADO.NET - Lesson 03  Training time: 15 minutes  Author:
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
 ADO.NET is an object-oriented set of libraries that allows you to interact with data sources  Commonly, the data source is a database, but it could.
The Holmes Platform and Applications
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
Lecture 6 VB.Net SQL Server.
Chris Menegay Sr. Consultant TECHSYS Business Solutions
Overview of Data Access
Overview of Data Access
ASP.NET Module Subtitle.
Chapter 10 ADO.
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
Presentation transcript:

DAT430 Extending Microsoft ® ADO.NET Building a Custom Data Factory API DAT430 Extending Microsoft ® ADO.NET Building a Custom Data Factory API Gert E.R. Drapers Architect Microsoft Corp.

Agenda ADO.NET Provider Architecture ADO.NET Provider Architecture Purpose of a Data Factory Purpose of a Data Factory Abstracting Statements Abstracting Statements Using Caching Using Caching

ADO.NET Concepts ADO.NET Architecture ADO.NET Architecture – Split into DataSet and.NET Data Providers – Exposes two distinct programming models Disconnected data Disconnected data Streamed data Streamed data – Use of these models affects your design decisions

.NET Data Provider IDataReader ExceptionError CommandBuilder IDbCommand IDataParameter IDbConnection Data Source IDbTransaction IDbDataAdapterDbDataAdapterIDataAdapterDataAdapter DataSet ADO.NET Architecture

SqlClient.NET Data Provider SqlDataReader DataSet SqlExceptionSqlError SqlCommandBuilder SqlCommand SqlParameter SqlConnection SQLServer SqlTransaction SqlDataAdapter ADO.NET Architecture

ADO.NET In Context Assume a multi-tier architecture Assume a multi-tier architecture – Separation of UI from data access code Role based development (data access specialist) Role based development (data access specialist) – Encapsulation of data access code into distinct classes Reusability and maintainability Reusability and maintainability Abstraction of the data source Abstraction of the data source – Data Access classes have both an external and internal view

Data Access Architecture External View External View – You choose how to represent the data Data Services (black box) Client (business or presentation services) ? = o.GetTitles(isbn) return ? DataSet Data Reader Custom Object

Data Access Architecture Internal View Internal View – Use one of these choices inside your data access classes Data Services Method Invoked from Client.NET Data Provider GetTitlesMethodBody Direct? ProviderFactory ? Data Factory DataSet Data readers ? Caching, other objects DataSet DataReaderCustomObject

demo demo Provider Factory

Purpose Of A Data Factory Reduce the amount of code you have to write Reduce the amount of code you have to write – By creating command objects and populating parameters automatically Provider Independence Provider Independence – Not locked into one.NET Data Provider Database Independence Database Independence – Target application for SQL Server or Oracle without changing any code! Performance Performance

Data Factory API CacheFilePath CacheFilePath Connection Connection Provider Provider UseCache UseCache BeginTransaction BeginTransaction CreateDataAdapter CreateDataAdapter CreateSqlFiles CreateSqlFiles CreateSqlFile CreateSqlFile ExecuteDataReader ExecuteDataReader ExecuteNonQuery ExecuteNonQuery ExecuteScalar ExecuteScalar ExecuteSqlXmlReader ExecuteSqlXmlReader GetDataSet GetDataSet GetDataTable GetDataTable GetProviders GetProviders GetXsltResults GetXsltResults RemoveStatement RemoveStatement SyncDataSet SyncDataSet SqlFilesCreated (event) SqlFilesCreated (event)

Data Factory Features Abstracts providers Abstracts providers – Hardcoded SqlClient and OleDb but configurable through DataFactory.config file Database Independent Database Independent – Uses statement files (XML) that abstract the SQL Caches Command Objects Caches Command Objects – Uses a synchronized Hashtable and relies on ICloneable interface

Provider Abstraction Relies on the Provider property Relies on the Provider property Uses System.Reflection to dynamically create the appropriate objects Uses System.Reflection to dynamically create the appropriate objects Can be extended for custom providers Can be extended for custom providers

demo demo Provider Abstraction

Database Independence Relies on statement files and two internal structures Relies on statement files and two internal structures – Synchronized provider-specific Hashtable for caching usp_GetTitles usp_GetTitles

demo demo Using Statement Files And Caching

Statement Files Can be created automatically using the CreateSqlFile and CreateSqlFiles shared methods Can be created automatically using the CreateSqlFile and CreateSqlFiles shared methods – Based on a procedure prefix – Works for SQL Server Uses sp_procedure_params_rowset Uses sp_procedure_params_rowset – CreateSqlFiles uses asynchronous delegate to run on a background thread

demo demo Creating Statement Files

Statement Flow Using a shared Hashtable Using a shared Hashtable Is statement in the cache? Load and parse statement file Pull out the command object and clone it Populate the parameters Return Command Execute a statement Create the command object with parameters No Yes

Using The Data Factory Public Function GetTitles(ByVal author As String, _ ByVal title As String) As DataSet dim cn As New SqlConnection(_connect) Dim daSql As SqlDataAdapter Dim parmSql As SqlParameter Dim ds As New DataSet() Try daSql = New SqlDataAdapter("usp_GetTitle", cn) daSql.SelectCommand.CommandType = CommandType.StoredProcedure parmSql = daSql.SelectCommand.Parameters.Add( _ New SqlDbType.varchar, 50)) parmSql.Value = author parmSql = daSql.SelectCommand.Parameters.Add( _ New SqlDbType.varchar, 200)) parmSql.Value = title daSql.Fill(ds) Return ds Catch e As SqlException ‘ Handle Error End Try End Function Try daSql = New SqlDataAdapter("usp_GetTitle", cn) daSql.SelectCommand.CommandType = CommandType.StoredProcedure parmSql = daSql.SelectCommand.Parameters.Add( _ New SqlDbType.varchar, 50)) parmSql.Value = author parmSql = daSql.SelectCommand.Parameters.Add( _ New SqlDbType.varchar, 200)) parmSql.Value = title daSql.Fill(ds) Return ds Catch e As SqlException ‘ Handle Error End Try End Function Client code before and after Client code before and after – Overall 30-40% reduction in code

Public Function GetTitles(ByVal author As String, _ ByVal title As String) As DataSet Dim parms As New HybridDictionary() Dim ds As New DataSet() Try parms.Add(“author”, author) parms.add(“title”, title) ds = _df.GetDataSet(“GetTitles”,parms) Return ds Catch e As DataFactoryException ‘ Handle Error End Try End Function Try parms.Add(“author”, author) parms.add(“title”, title) ds = _df.GetDataSet(“GetTitles”,parms) Return ds Catch e As DataFactoryException ‘ Handle Error End Try End Function Client code before and after Client code before and after – Overall 30-40% reduction in code Using The Data Factory

Performance and Futures Results from Application Center Test Results from Application Center Test – In an ASP.NET application the site performed slightly better using the DataFactory – Could be improved by caching the creation of the type objects

Questions?

Resources from Microsoft Press For more information please visit the TechEd Bookshop. ADO.NET

Don’t forget to complete the on-line Session Feedback form on the Attendee Web site