Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# and the NET Platform, Second Edition - Andrew Troelsen.pdf
Скачиваний:
67
Добавлен:
24.05.2014
Размер:
22.43 Mб
Скачать

Summary C# and the .NET Platform, Second Edition

by Andrew Troelsen ISBN:1590590554

This chapter began by examining the use of the Directory(Info) and File(Info) types. As you have seen,

Apress © 2003 (1200 pages)

these classes allow you to manipulate a physical file or directory on your hard drive.

This comprehensive text starts with a brief overview of the

C# language and then quickly moves to key technical and

Next you examined a number of types derived from the abstract Stream class, including FileStream, architectural issues for .NET developers.

MemoryStream, and BufferedStream. Given that each of these types has (more or less) the same public interface, you can easily swap them in and out of your code to alter the ultimate location of your byte array.

TableWhenofyouContentsare interested in persisting textual data, the StreamReader and StreamWriter types usually fit

C#theandbillthe. .NET Platform, Second Edition

Introduction

We wrapped things up by investigating how the types of the System.IO namespace can be used in

Part One - Introducing C# and the .NET Platform

conjunction with .NET object serialization services to persist custom types to a given location.

Chapter 1 - The Philosophy of .NET

Chapter 2 - Building C# Applications

Part Two - The C# Programming Language

Chapter 3 - C# Language Fundamentals

Chapter 4 - Object-Oriented Programming with C#

Chapter 5 - Exceptions and Object Lifetime

Chapter 6 - Interfaces and Collections

Chapter 7 - Callback Interfaces, Delegates, and Events

Chapter 8 - Advanced C# Type Construction Techniques

Part Three - Programming with .NET Assemblies

Chapter 9 - Understanding .NET Assemblies

Chapter 10 - Processes, AppDomains, Contexts, and Threads

Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming

Part Four - Leveraging the .NET Libraries

Chapter 12 - Object Serialization and the .NET Remoting Layer

Chapter 13 - Building a Better Window (Introducing Windows Forms)

Chapter 14 - A Better Painting Framework (GDI+)

Chapter 15 - Programming with Windows Forms Controls

Chapter 16 - The System.IO Namespace

Chapter 17 - Data Access with ADO.NET

Part Five - Web Applications and XML Web Services

Chapter 18 - ASP.NET Web Pages and Web Controls

Chapter 19 - ASP.NET Web Applications

Chapter 20 - XML Web Services

Index

List of Figures

List of Tables

Chapter C#17:andDatathe .NETAccessPlatform, SecondwithEditionADO.NET

by Andrew Troelsen

ISBN:1590590554

Apress © 2003 (1200 pages)

 

Overview This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and

Unless you are aarchitecturalvideo gameissudevelopers for .NETby trade,dev lopersyou are. probably interested in database manipulation. As you would expect, the .NET platform defines a number of types (in a handful of related namespaces) that allow you to interact with local and remote data stores. Collectively speaking, these namespaces are

Tableknownof Contentsas ADO.NET, which as you will see is a major overhaul of the classic ADO object model.

C# and the .NET Platform, Second Edition

This chapter begins by examining some core types defined in the System.Data namespace-specifically

Introduction

DataColumn, DataRow, and DataTable. These classes allow you to define and manipulate a local in-

Part One - Introducing C# and the .NET Platform

memory table of data. Next, you spend a good deal of time learning about the centerpiece of ADO.NET,

Chapter 1 - The Philosophy of .NET

the DataSet. As you will see, the DataSet is an in-memory representation of a collection of interrelated

Chapter 2 - Building C# Applications

tables. During this discussion, you will learn how to programmatically model table relationships, establish

Part Two - The C# Programming Language

custom views based on a given DataTable, and submit queries against your in-memory DataSet.

Chapter 3 - C# Language Fundamentals

Chapter 4 - Object-Oriented Programming with C#

After examining how to manually build and manipulate a DataSet by hand, you'll examine how to obtain a

Chapter 5 - Exceptions and Object Lifetime

populated DataSet from a Database Management System (DBMS) such as MS SQL Server, Oracle, or ChapterMS Access6 -.InterfacesDuring theandprocess,Collectionsyou will examine the role of .NET data providers and come to understand

Chapterthe use7of-ADOCallback.NETInterfaces,data adapters,Delegates,commandEventsobjects, and command builders.

Chapter 8 - Advanced C# Type Construction Techniques

In contrast to the intrinsically disconnected world of DataSets and data adapters, this chapter also

Part Three - Programming with .NET Assemblies

examines the connected layer of ADO.NET and the related data reader types. As you will see, the data

Chapter 9 - Understanding .NET Assemblies

reader is ideal when you simply wish to obtain a result set from a data store for display purposes. We wrap

Chapter 10 - Processes, AppDomains, Contexts, and Threads

things up with an overview of various database-centric wizards of Visual Studio .NET, and come to see

Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming

how these integrated tools can be used to lessen the amount of ADO.NET code you would otherwise need

Part Four - Leveraging the .NET Libraries

to write by hand.

Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)

Chapter 15 - Programming with Windows Forms Controls

Chapter 16 - The System.IO Namespace

Chapter 17 - Data Access with ADO.NET

Part Five - Web Applications and XML Web Services

Chapter 18 - ASP.NET Web Pages and Web Controls

Chapter 19 - ASP.NET Web Applications

Chapter 20 - XML Web Services

Index

List of Figures

List of Tables

The Need forC# andADOthe.NET. T Platform, Second Edition

by Andrew Troelsen

ISBN:1590590554

The very first thing you must understand when approaching ADO.NET is that it is not simply the latest and

Apress © 2003 (1200 pages)

greatest version of classic ADO. While it is true that there is some symmetry between the two systems

This comprehensive text starts with a brief overview of the

(e.g., each has theC#conceptlanguageofandconnectionth n quicklyandmcommandves to keyobjects),t chnicalsomeand familiar types (e.g., the Recordset) no longerarchitexistctural. Furthermore,issu s for .NETthered velopersare a number. of new ADO.NET types that have no direct equivalent under classic ADO (such as the data adapter). In a nutshell, ADO.NET is a brand new database access technology focused on facilitating the development of disconnected (and connected)

Table of Contents

systems using the .NET platform.

C# and the .NET Platform, Second Edition

Unlike classic ADO, which was primarily designed for tightly coupled client/server systems, ADO.NET

Introduction

greatly extends the notion of the primitive ADO disconnected Recordset with a new creature named the

Part One - Introducing C# and the .NET Platform

DataSet. This type represents a local copy of any number of related tables. Using the DataSet, the client is

Chapter 1 - The Philosophy of .NET

able to manipulate and update its contents while disconnected from the data source and submit the

Chapter 2 - Building C# Applications

modified data back for processing using a related data adapter.

Part Two - The C# Programming Language

Chapter 3 - C# Language Fundamentals

Another major difference between classic ADO and ADO.NET is that ADO.NET has full support for XML

Chapter 4 - Object-Oriented Programming with C#

data representation. In fact, the data obtained from a data store is internally represented, and transmitted,

Chapter 5 - Exceptions and Object Lifetime

as XML. Given that XML is often transported between layers using standard HTTP, ADO.NET is not limited

Chapter 6 - Interfaces and Collections by firewall constraints.

Chapter 7 - Callback Interfaces, Delegates, and Events

As you might be aware, classic ADO makes use of the COM marshaling protocol to move data between

Chapter 8 - Advanced C# Type Construction Techniques

tiers. While this was appropriate in some situations, COM marshaling poses a number of limitations. For

Part Three - Programming with .NET Assemblies

example, most firewalls are configured to reject COM RPC packets, which made moving data between

Chapter 9 - Understanding .NET Assemblies

machines tricky.

Chapter 10 - Processes, AppDomains, Contexts, and Threads

Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming

Perhaps the most fundamental difference between classic ADO and ADO.NET is that ADO.NET is a

Part Four - Leveraging the .NET Libraries

managed library of code and therefore plays by all the same rules as any managed library. The types that

Chapter 12 - Object Serialization and the .NET Remoting Layer

comprise ADO.NET use the CLR memory management protocol, adhere to the same programming

Chapter 13 - Building a Better Window (Introducing Windows Forms)

model, and work with many languages. Therefore, the types (and their members) are accessed in the

Chapter 14 - A Better Painting Framework (GDI+)

same manner, regardless of which .NET-aware language you use.

Chapter 15 - Programming with Windows Forms Controls

Chapter 16 - The System.IO Namespace

Chapter 17 - Data Access with ADO.NET

Part Five - Web Applications and XML Web Services

Chapter 18 - ASP.NET Web Pages and Web Controls

Chapter 19 - ASP.NET Web Applications

Chapter 20 - XML Web Services

Index

List of Figures

List of Tables

The Two FacesC# andoftheADO.NET Platform,.NET Second Edition

by Andrew Troelsen

ISBN:1590590554

The ADO.NET libraries can be used in two conceptually unique manners: connected or disconnected.

Apress © 2003 (1200 pages)

When you are making use of the connected layer, you will make use of a .NET data reader. As you will

This comprehensive text starts with a brief overview of the

see later in this chapter,C# langudatage readersand thenprovidequickly amovesway totopullkeyrecordste hnicalfromand a data store using a forward-only, read-only approacharchitectural(much likeissuesa fireforhose.NETcursor)developers. As a. given data reader pulls over records based on your SQL query, you are directly connected to the data store and stay that way until you explicitly close the connection. In addition to simply reading data via a data reader, the connected layer of ADO.NET allows

Table of Contents

you to insert, update, or remove records using a related command object.

C# and the .NET Platform, Second Edition

The disconnected layer, on the other hand, allows you to obtain a set of DataTable types (typically

Introduction

contained within a DataSet) that serves as a local client-side copy of information. When you obtain a

Part One - Introducing C# and the .NET Platform

DataSet using a data adapter type, the connection is automatically terminated immediately after the fill

Chapter 1 - The Philosophy of .NET

request (as you would guess, this approach helps quickly free up connects for other callers). At this point,

Chapter 2 - Building C# Applications

the client application is able to manipulate the DataSet's contents without incurring any network traffic. If

Part Two - The C# Programming Language

the client wishes to push the changes back to the data store, the data adapter (in conjunction with a set of

Chapter 3 - C# Language Fundamentals

SQL queries) is used once again to update the data source, at which point the connection is again closed

Chapter 4 - Object-Oriented Programming with C#

immediately.

Chapter 5 - Exceptions and Object Lifetime

Chapter 6 - Interfaces and Collections

In some respects, this approach may remind you of the classic ADO disconnected Recordset. The key

Chapter 7 - Callback Interfaces, Delegates, andrepresentsEv

difference is that a disconnected Recordset a single set of record data, whereas ADO.NET ChapterDataSets8 can- AdvancmodeldaC#collectionType Constructionof related Techniquestables. In fact, it is technically possible to obtain a client-side

PartDataSetThr ethat- Programmingrepresents allwithof .theNETtablesAssembliesfound within the remote database. However, as you would expect,

Chaptera DataSet9 -willUnderstandingmore commonly.NET Assembliescontain a reasonable subset of information.

Chapter 10 - Processes, AppDomains, Contexts, and Threads

Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming

Part Four - Leveraging the .NET Libraries

Chapter 12 - Object Serialization and the .NET Remoting Layer

Chapter 13 - Building a Better Window (Introducing Windows Forms)

Chapter 14 - A Better Painting Framework (GDI+)

Chapter 15 - Programming with Windows Forms Controls

Chapter 16 - The System.IO Namespace

Chapter 17 - Data Access with ADO.NET

Part Five - Web Applications and XML Web Services

Chapter 18 - ASP.NET Web Pages and Web Controls

Chapter 19 - ASP.NET Web Applications

Chapter 20 - XML Web Services

Index

List of Figures

List of Tables

Соседние файлы в предмете Программирование