Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

expert asp.net 2.0 advanced application design
PREMIUM
Số trang
481
Kích thước
11.3 MB
Định dạng
PDF
Lượt xem
1107

expert asp.net 2.0 advanced application design

Nội dung xem thử

Mô tả chi tiết

www.it-ebooks.info

Dominic Selly

Andrew Troelsen

Tom Barnaby

Expert ASP.NET 2.0

Advanced Application Design

522xFM.qxd 8/31/05 3:54 PM Page i

www.it-ebooks.info

Expert ASP.NET 2.0 Advanced Application Design

Copyright © 2006 by Dominic Selly, Andrew Troelsen, and Tom Barnaby

Lead Editor: Ewan Buckingham

Technical Reviewers: Robert Lair, Rakesh Rajan, Victor Garcia Aprea, Fernando Simonazzi,

Hernan De Lahitte

Contributors: Dave Zimmerman, David Schueck, George Politis

Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis,

Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser

Associate Publisher: Grace Wong

Project Manager: Beckie Stones

Copy Edit Manager: Nicole LeClerc

Copy Editor: Lauren Kennedy

Assistant Production Director: Kari Brooks-Copony

Production Editor: Kelly Winquist

Compositor: Dina Quan

Proofreader: Nancy Sixsmith

Indexer: Broccoli Information Management

Artist: Wordstop

Interior Designer: Van Winkle Design Group

Cover Designer: Kurt Krames

Manufacturing Manager: Tom Debolski

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,

electronic or mechanical, including photocopying, recording, or by any information storage or retrieval

system, without the prior written permission of the copyright owner and the publisher.

Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1

Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence

of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark

owner, with no intention of infringement of the trademark.

Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,

New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or

visit http://www.springeronline.com.

For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,

CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com.

The information in this book is distributed on an “as is” basis, without warranty. Although every precaution

has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to

any person or entity with respect to any loss or damage caused or alleged to be caused directly or indi￾rectly by the information contained in this work.

The source code for this book is available to readers at http://www.apress.com in the Source Code section.

522xFM.qxd 8/31/05 3:54 PM Page ii

www.it-ebooks.info

Patty made Lucy

while I made this book, and so

I give it to them.

—dws

522xFM.qxd 8/31/05 3:54 PM Page iii

www.it-ebooks.info

522xFM.qxd 8/31/05 3:54 PM Page iv

www.it-ebooks.info

Contents at a Glance

About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

PART 1 ■ ■ ■ ASP.NET 2.0 Internals

■CHAPTER 1 Overview of .NET Application Architecture . . . . . . . . . . . . . . . . . . . . . . 3

■CHAPTER 2 The ASP.NET Request Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

■CHAPTER 3 Page Object Internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

■CHAPTER 4 ViewState and Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

PART 2 ■ ■ ■ .NET Middle Tier Solutions

■CHAPTER 5 .NET 2.0 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

■CHAPTER 6 SOA in .NET: Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

■CHAPTER 7 Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

■CHAPTER 8 Hosting and Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

■CHAPTER 9 Windows Communication Foundation . . . . . . . . . . . . . . . . . . . . . . . . . 297

PART 3 ■ ■ ■ Data Access Layer

■CHAPTER 10 Managed Providers of Data Access . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

■CHAPTER 11 Data Access Layer Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

■CHAPTER 12 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

v

522xFM.qxd 8/31/05 3:54 PM Page v

www.it-ebooks.info

522xFM.qxd 8/31/05 3:54 PM Page vi

www.it-ebooks.info

Contents

About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

PART 1 ■ ■ ■ ASP.NET 2.0 Internals

■CHAPTER 1 Overview of .NET Application Architecture . . . . . . . . . . . . . . . . 3

Nonfunctional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Scalability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Vertical Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Horizontal Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Maintainability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Other Nonfunctional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Service Oriented Architecture/Service Orientation . . . . . . . . . . . . . . . . . . . 15

.NET Application Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

A Simple Managed Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Using Serviced Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

A Widely Distributed Service Application . . . . . . . . . . . . . . . . . . . . . . 23

An Asynchronous Messaging Architecture . . . . . . . . . . . . . . . . . . . . . 26

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

■CHAPTER 2 The ASP.NET Request Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Application and Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

The HttpApplication Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Built-in Framework Extensions to the Pipeline . . . . . . . . . . . . . . . . . 40

Extending the Request Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Inheriting from HttpApplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Implementing an HttpModule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 vii

522xFM.qxd 8/31/05 3:54 PM Page vii

www.it-ebooks.info

HTTP Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Handlers Built into the Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Creating an Http Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

■CHAPTER 3 Page Object Internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Structure of a Web Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Options for Building Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Code Generation of ASPX Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Code Generation of ASPX Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Compilation and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Dynamic Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Precompilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Basics of the Control Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

Control Tree Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Web Form Event Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Control Events vs. Page Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

The Special Role of the PreRender Event . . . . . . . . . . . . . . . . . . . . . . 90

Resource Consumption when Data Binding . . . . . . . . . . . . . . . . . . . . . . . . 93

Capturing the Rendered Output Stream . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

■CHAPTER 4 ViewState and Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

The Role of ViewState in ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

The ViewState Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

2.0 ViewState Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Replacing ViewState Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

Post-Cache Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

Page Support for Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Out-of-Band Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

PART 2 ■ ■ ■ .NET Middle Tier Solutions

■CHAPTER 5 .NET 2.0 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

A Survey of Core Security Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

The Role of Strongly Named Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . 148

An Example of Round Tripping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

Preventing Roundtrip Engineering via Strong Naming . . . . . . . . . . 150

viii ■CONTENTS

522xFM.qxd 8/31/05 3:54 PM Page viii

www.it-ebooks.info

Encryption Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Understanding Hash Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Hashing a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Role-Based Security (RBS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Restricting Access Based On User Identity . . . . . . . . . . . . . . . . . . . . 157

Securing ASP.NET Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

Understanding Configuration Inheritance . . . . . . . . . . . . . . . . . . . . . 159

Understanding ASP.NET Authentication Options . . . . . . . . . . . . . . . . . . . . 160

Windows-Based Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Passport-Based Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Forms-Based Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

Leveraging the Forms Authentication Model . . . . . . . . . . . . . . . . . . . . . . . 163

Details behind the <authentication> Element . . . . . . . . . . . . . . . . . . . . . 165

Details behind the <forms> Element . . . . . . . . . . . . . . . . . . . . . . . . 166

Cookieless Authentication Support under ASP.NET 2.0 . . . . . . . . . 167

Details behind the <authorization> Element . . . . . . . . . . . . . . . . . . . . . . . 168

Details behind the FormsAuthentication Type . . . . . . . . . . . . . . . . . . . . . . 169

Working with the <credentials> Element . . . . . . . . . . . . . . . . . . . . . 170

Forms Authentication Improvements under ASP.NET 2.0 . . . . . . . . . . . . 171

Understanding the Membership Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

Specifying a Membership Provider for your Website . . . . . . . . . . . 173

Adding New Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

The MembershipUser Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Updating a User’s Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

Deleting a User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

Working with the Security Server Controls . . . . . . . . . . . . . . . . . . . . . . . . 178

The Login Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

The LoginStatus Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

The LoginName Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

The PasswordRecovery Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

The ChangePassword Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

The CreateUserWizard Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

Understanding ASP.NET 2.0 Role Membership . . . . . . . . . . . . . . . . . . . . . 186

Enabling Role Membership Services . . . . . . . . . . . . . . . . . . . . . . . . . 187

Understanding the Roles Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

Creating, Obtaining, and Deleting Roles . . . . . . . . . . . . . . . . . . . . . . 189

Assigning Users to Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

Determining Role Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

ASP.NET Web Application Administration Tool . . . . . . . . . . . . . . . . . . . . . . 191

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

■CONTENTS ix

522xFM.qxd 8/31/05 3:54 PM Page ix

www.it-ebooks.info

■CHAPTER 6 SOA in .NET: Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

SO What? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

SO What Are the Themes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Web Services as an SO Implementation . . . . . . . . . . . . . . . . . . . . . . 202

ASMX and the Web Service Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

2.0 ASMX Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

Other Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

WS-I and WSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Operational Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

WS-Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

■CHAPTER 7 Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

Component Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

COM+ in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

COM+ Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

Just-In-Time Activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

Object Pooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Queued Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

Role-Based Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Some Practices Worth Observing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

■CHAPTER 8 Hosting and Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

Processes and Marshaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

Internet Information Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

ASP.NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

Component Service SOAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

Stored Procedure SOAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

DLLHost and DCOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

Message Queuing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Custom Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

x ■CONTENTS

522xFM.qxd 8/31/05 3:54 PM Page x

www.it-ebooks.info

■CHAPTER 9 Windows Communication Foundation . . . . . . . . . . . . . . . . . . . 297

Introducing Windows Communication Foundation . . . . . . . . . . . . . . . . . . 297

What Is Windows Communication Foundation? . . . . . . . . . . . . . . . 297

Understanding the WCF Motivations . . . . . . . . . . . . . . . . . . . . . . . . . 298

YASOE: Yet Another Service Orientation Explanation . . . . . . . . . . . . . . . . 300

SO/A: Revolution, Evolution, or Neither? . . . . . . . . . . . . . . . . . . . . . . 300

Objects vs. Services: The Metaphor Matters . . . . . . . . . . . . . . . . . . 301

The Four Tenets of Service Orientation . . . . . . . . . . . . . . . . . . . . . . . 301

Service Orientation vs. Service Oriented Architecture . . . . . . . . . . 303

Programming with WCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

The ABCs of WCF: Address, Binding, and Contract . . . . . . . . . . . . . 304

Hosting the Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

Calling the Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

Revisiting WCF Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

Instancing, Transactions, and Much, Much More . . . . . . . . . . . . . . 312

Preparing for WCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312

Will WCF Break My Current Application? . . . . . . . . . . . . . . . . . . . . . 313

Will My Implementation Interoperate with WCF? . . . . . . . . . . . . . . 313

How Easily Will my Application Migrate to WCF? . . . . . . . . . . . . . . 314

Interoperability and Migration Summary . . . . . . . . . . . . . . . . . . . . . 316

Overall Guidance for Choosing the Best Technology . . . . . . . . . . . 317

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

PART 3 ■ ■ ■ Data Access Layer

■CHAPTER 10 Managed Providers of Data Access . . . . . . . . . . . . . . . . . . . . . . 321

Managed Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

System.Data Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Data Readers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

DataSets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Managed Provider Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356

Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

■CONTENTS xi

522xFM.qxd 8/31/05 3:54 PM Page xi

www.it-ebooks.info

■CHAPTER 11 Data Access Layer Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

Declarative Data Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

SQL Data Source Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

Object Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

Dependent Cache Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

SQL Cache Dependency Configuration . . . . . . . . . . . . . . . . . . . . . . . 389

Programming with SQL Cache Dependencies . . . . . . . . . . . . . . . . . 391

Automating SQL Cache Dependency Administration . . . . . . . . . . . 392

Data Access Application Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

Configuration and the Database Object . . . . . . . . . . . . . . . . . . . . . . 399

Data Access Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

The Command Wrapper Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

Parameters and the Parameter Cache . . . . . . . . . . . . . . . . . . . . . . . 405

Using the Data Access Block for Transaction Management . . . . . 407

A Developer’s Survey of SQL Server 2005 . . . . . . . . . . . . . . . . . . . . . . . . . 408

CLR Integration in SQL Server 2005 . . . . . . . . . . . . . . . . . . . . . . . . . 409

SQL Server 2005 Service Broker . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

Native XML Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

■CHAPTER 12 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

Transactions in 1.x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

Transactions in 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426

Lightweight Transaction Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

Programming Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

Transacted Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

xii ■CONTENTS

522xFM.qxd 8/31/05 3:54 PM Page xii

www.it-ebooks.info

About the Authors

■DOMINIC SELLY is an Intertech trainer and consultant. Dominic is a fre￾quent presenter at developer conferences. He is also a coauthor of Visual

Basic .NET at Work (Wiley, 2002). Dominic has been creating software for

more than a dozen years.

Dominic has also been teaching developers for many years, in topics

including ASP.NET, VB.NET, C#, XML, Visual Basic, ASP, and SQL Server.

He is the author of several of Intertech Training’s courses, including Com￾plete ASP.NET, .NET for Architects, and much of their Web Services curriculum. Dominic also

co-created the Web Application Development Certificate program offered at George Washing￾ton University in Washington D.C.

Dominic spends his spare time trying to master the perfect determinism of the game of

pocket billiards.

■ANDREW TROELSEN is a Microsoft C# MVP and partner/vice president of

Training and Technology at Intertech Training, where he has worked for

more than eight years. He teaches and mentors America’s leading organi￾zations (including NASA, Microsoft Corporation, Honeywell, Lockheed

Martin, Wells Fargo, and the Mayo Clinics) regarding the ways of .NET,

and if duty calls, the Component Object Model (COM).

He is also the author of Visual Basic .NET and the .NET Platform: An

Advanced Guide (Apress, 2001), COM and .NET Interoperability (Apress, 2002), and Developer's

Workshop to COM and ATL 3.0 (Wordware Publishing, 2002).

When he has a spare moment, he enjoys re-creating the games he once programmed for

his Atari 400 using C# and the BCL, spending too much time with his XBox; cheering for the

Timberwolves, Wild, and Vikings; and doing whatever possible to return to the Gunflint Trail.

■TOM BARNABY is a Microsoft Consultant, C# MVP, national speaker, and

author of several .NET books including Distributed .NET Programming

in C# and Applied .NET Attributes (Apress, 2002). In his spare time, Tom

enjoys playing with his two sons, watching movies in the family home

theater room, and banging out power chords on his electric guitar with

the volume turned to 11.

xiii

522xFM.qxd 8/31/05 3:54 PM Page xiii

www.it-ebooks.info

522xFM.qxd 8/31/05 3:54 PM Page xiv

www.it-ebooks.info

Tải ngay đi em, còn do dự, trời tối mất!