A First Look at ADO.NET and System.Xml 2.0



Accessing data has long been the prime requirement of Web site and Web application developers. This data has traditionally been located in a relational database, but in recent years the rise in the use of XML as a data persistence and transport format has forced data access technologies to change. In version 1.x of the .NET Framework, with ADO.NET and the classes in the System.Xml namespaces, we saw how Microsoft is tackling these changing requirements, where applications not only have to handle different data formats and data stores, but do so in a way that makes sense in an increasingly disconnected environment.


Now version 2.0 of the .NET Framework is starting to appear on the horizon. Sometime in 2004 we should see a final release, together with new versions of Visual Studio and other tools. In the meantime, Microsoft are following their usual policy of involving developers as early in the process as possible, giving them the chance to provide feedback on the new product.


So, as the final release of version 2.0 is still some way off, why would you be interested in it now? The simple answer is, of course, that — as a developer — you need to keep abreast of what's going on in your industry. And more than that, being aware of what's coming in the future might well influence what you do today, in the overall design of your applications and the preparations and plans you are making for upcoming products and applications.


This book will help by introducing you to the new features that will be in version 2.0, and how they can fulfill the requirements for data management in your applications. It may be that you don't actually intend to install the early releases of version 2.0, and you just want to know more about what it offers. No problem - that's OK with us as well!


Important Note: Code Downloads, Versions and Release Schedules

Before you read any further, it's important that you understand what this book covers, and how it relates to the future and final releases of .NET version 2.0.


The current release of the .NET Frameworks is a "Technical Preview" or "Alpha" version, based on the second of three milestones specified during development of v 2.0. There will probably also be two or more "Beta" releases, starting early in 2004, and followed by a final release.


This book covers the "Technical Preview" release, but also discusses the plans for changes and extensions to the features in the Beta releases that will follow. What this effectively means is that the class interface listings and code samples you see here cannot be guaranteed to work in exactly the same way right through to the final release version.


Therefore, in order to make this book as useful as possible we are maintaining a Web site that details changes throughout the Beta cycle and up to final release of v 2.0. This site is at http://www.daveandal.net/da/dotnet2beta/. You'll also find news about release dates as it becomes available, more code examples, etc. You can also download the code for the book, and subsequent updates, from the same place.


What This Book Covers

This is not just a reference book, but instead is a feature-packed exploration of ADO.NET 2.0 and System.Xml 2.0. It covers the changes between version 1.x and version 2.0, describing the new features that can improve data access efficiency, give you easier access to object-type data, provide better support for XML-based data management, and take advantage of the new features in SQL Server "Yukon".


The first chapter presents an overview of the new version. It also lays out the roadmap for the remainder of the book, splitting the content into two sections: relational data management (the next four chapters) and XML-based data management (the final four chapters). Each of these blocks of chapters is broken down into individual topic sections, covering the new and changed features in logical groups. 


Along with the final release of .NET 2.0 we will, of course, see a new version of Visual Studio.NET and other tools. However, as this is not available at the time of writing, we do not use it in this book. Many developers starting out with version 2.0 will be writing their code as console applications or ASP.NET pages using other tools (including, we suspect, a text editor) while Visual Studio.NET is still being developed.


What You Need To Use This Book

The main thing you need to use this book is one of the "Alpha" or "Beta" releases of version 2.0 of the .NET Framework release. The first "Technical Preview" or "Alpha" release is due late in 2003, and the book is based on this version.


Other than that, you'll need something to transfer your creative efforts into console application or ASP.NET files on disk. It really doesn't really matter which tool or editor you use as long as it can generate text files with the .vb, .cs or .aspx file extension.


Finally, to take advantage of some of the techniques now available in ADO.NET, you'll need to install the latest version of the Microsoft Data Access Components library (MDAC), and to use the "Yukon" specific features you'll obviously also need to have access to an instance of SQL Server "Yukon".



Chapter 1 - ADO.NET and System.Xml v2.0

·          The Version 2.0 Technology Preview Release

·          Enhancements in Relational Data Management

·          Enhancements in XML Data and Document Management

·          Summary of New Features in Version 2.0

·          Summary of New Features in ADO.NET

·          Summary of New Features in System.Xml

·          The Growing Importance of XML

·          The Changing XML Landscape

·          XML and Relational Databases

·          XML in Web Applications

·          XML Content Publishing

·          XML in the .NET Framework

·          Relational Data Binding in ASP.NET

·          ASP.NET Data Source Controls and GridView Control

·          A Roadmap for This Book

·          Summary


Chapter 2 - Bulk Loading, Batch Execution and Paging

·          The New Bulk Data Copy Features

·          The SqlBulkCopyOperation Class

·          Bulk Copy Column Associations

·          The SqlBulkCopyColumnAssociator Class

·          The SqlBulkCopyColumnAssociatorCollection Class

·          A Simple Bulk Copy Example Using a DataReader

·          Multiple Bulk Copy Operations and Events Using a DataSet

·          The New Batched Update Features

·          Batched Command Execution with a DataSet and DataAdapter

·          Data Paging with the Command Object

·          The ExecutePageReader Method

·          Retrieving Connection Statistics

·          A Simple Statistics Retrieval Example

·          Summary


Chapter 3 - MARS, Async Commands and ObjectSpaces

·          Expanded and Improved Data Access Features

·          Accessing a Single Data Source

·          Accessing Multiple Data Sources

·          Multiple Active Result Sets (MARS)

·          An Example of MARS in Action

·          Asynchronous Command Execution

·          Asynchronous Classes, Methods and Properties

·          The Asynchronous Polling Model

·          The Asynchronous Callback Model

·          The Asynchronous Wait Model

·          Canceling Processing for Asynchronous Commands

·          Asynchronously Opening Connections

·          Catching Asynchronous Processing Errors

·          An Overview of ObjectSpaces

·          Basic ObjectSpaces Techniques

·          Object Mappings

·          Hierarchical Data

·          Summary


Chapter 4 - ADO.NET and SQL Server Yukon

·          SQL Server Query Notifications

·          An Overview of Query Notifications

·          Setting Up a Notification

·          Using SqlDependency in ASP.NET Applications

·          SQL Server User-defined Types

·          UDT Installed on the Client and the Database

·          Downloading the UDT Assembly On Demand

·          UDT Not Available on the Client

·          Using UDTs in Query Parameters

·          Interface Changes to Support UDTs

·          Managed Code, Server-side Cursors and Result Sets

·          Using Server-side Cursors to Access Data Rows Directly

·          Server-side Cursors and Result Sets

·          The Classes and Methods That Support Result Sets

·          Using the SqlResultSet Class

·          Summary


Chapter 5 - New Features of System.Xml

·          Why Do I Care About XML?

·          System.Xml Version 1.x

·          Version 1.x Design Goals

·          XML Reading and Writing

·          XML Document Editing

·          XML Validation or Content Checking

·          XML Querying

·          XSL Transformation

·          The Quest for Universal Data Access

·          XML Providers

·          Integration with ADO.NET

·          Which Data Model?

·          Relational, XML or Objects?

·          The Changing XML Landscape

·          Growing XML Content Generation.

·          XML Storage

·          The Need for another XML Query language

·          What's New in System.Xml Version 2.0

·          Middle Tier XML Data Access

·          XML Views - Extending the XML Provider Model.

·          XML Views Mapping Format, XSD, MSD and RSD Schemas (Three-Part Mapping)

·          The XPathDocument2 Class - An Editable XML Store with Change Tracking

·          The XmlAdapter. An ADO.NET class to Query and Update SQL Server Tables as XML

·          XQuery Programming

·          XQuery and XML Views

·          XSLT Programming

·          Summary


Chapter 6 - The XPathDocument2 Class 

·          The XPathDocument2 Class

·          An Introduction to Creating and Updating the XPathDocument2 Class

·          An Overview of the XPathDocument2 Class

·          Properties and Methods for the XPathDocument2 Class and Dependent Classes

·          Constructors

·          Properties

·          Methods

·          Events

·          XPathDocument2ChangedEventsArgs Class

·          Enumerations

·          The XPathEditor and XPathChangeNavigator Classes

·          The XPathEditor Class

·          The XPathChangeNavigator Class

·          Using the XPathEditor Class with the XPathDocument2

·          Using the XPathChangeNavigator Class with the XPathDocument2

·          Using the XPathDocument2 Class

·          Summary


Chapter 7 - The XmlAdapter and SqlXml Classes

·          The XmlAdapter Class and XML Views

·          The XmlAdapter Class

·          The XmlUpdateEventArgs Class

·          The XmlDataSourceResolver Class

·          XML Views using XSD, MSD and RSD Schemas (Three-Part Mapping)

·          Breaking Down the MSD Mapping

·          XmlViewSchema and XmlViewSchemaDictionary Classes

·          The System.Data.Mapping Namespace

·          Updating SQL Server With the XmlAdapter Class

·          The map:view command and XQuery

·          Using the Fill Method with an XPathDocument2

·          Using Parameters with the Fill Method

·          The Update Method with an XPathDocument2

·          The Update Method with an XPathChangeNavigator

·          Handling Update Errors

·          Tips and Tricks When Working With the XmlAdapter

·          Tips and Tricks when working with XML Views

·          Migrating from SQLXML3.0 to the .NET Framework

·          The XmlBulkLoad Class

·          The DBObject Class

·          The XmlRowsetAdapter Class

·          XML Data Source Controls and Data Binding

·          Using an XML Data Source Control

·          The DataSetDataSource control

·          The WebServiceDataSource control

·          Summary


Chapter 8 - XQuery and SQL Server

·          A Very Brief Overview of the XQuery Language

·          Where’s the data located?

·          FLWOR Expressions

·          The XQueryProcessor Class

·          The Properties and Methods for the XQueryProcessor Class

·          The XmlCommand Class

·          Querying XML Documents with the XQueryProcessor Class

·          Querying Multiple XML Documents with the XQueryProcessor Class

·          Using the XQueryProcessor Class with an XML View

·          Using the XQueryProcessor Class with Multiple XML Views

·          Using an XQueryProcessor with Multiple XML Views and Multiple Database Connections

·          Using the XQueryProcessor Class with Multiple XML Views and XML Documents

·          The XsltProcessor Class

·          Transforming XML Documents with the XsltProcessor Class

·          The Common Query Architecture

·          SQL Server as an XML Database

·          The XML Data Type in SQL Server Yukon

·          The XML Schema Repository in SQL Server Yukon

·          Inserting and Selecting with an XML Data Column

·          Querying and Updating the Contents of an XML Data Column

·          Indexing an XML Data Column

·          Summary


©2003, Stonebroom Limited England