Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign: ...

49

Transcript of Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign: ...

Page 1: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,
Page 2: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

A Strategic Comparison of Data Access Technologies from Microsoft

Michele Leroux Bustamante IDesignDTL201

Page 3: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Michele Leroux BustamanteChief Architect IDesign: www.idesign.net

Microsoft Regional Director, MVP Connected Systems

Published Author:ASP.NET Pro (WCF Column), MSDN, CoDeLearning WCF (O’Reilly 2007/2008/2009)

Speaker:Tech Ed, PDC, Dev Connections, other

international events

Blogs:www.dasblonde.net (main)www.thatindigogirl.com (book)

Page 4: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Data Access Technologies

DataSetDataReaderLINQ to SQLEntity FrameworkADO.NET Data Services

Page 5: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Managed Data Provider

IDbConnectionIDbCommand

DataSet

Client

IDataReader

Client

IDbDataAdapter

ADO.NET 1.x Architecture

Page 6: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataSet

Support data binding, caching, offline work, change tracking, CRUD operationsCode gen with strongly-typed datasets Great for rapid prototypingDatabase support via provider modelConsiderable bloatNot interoperableCumbersome object model

Page 7: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataSet Scenarios

DALCRUD operations with minimal codeCode gen with strongly-typed set

Service

BusinessComponents

Data Access

SQL

DataSet

Entities

Mapping

Data Contracts / Serializable

Data Access Layer with DataSet

Page 8: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataSet Scenarios

ASP.NETTwo-way data binding via ObjectDataSourceRequires a data access layer or service proxy

Data Access

SQL

Browser

ASP.NET

ObjectDataSource

DataSet

Service

ASP.NET DataSet Binding

Page 9: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataSet Scenarios

Windows Forms and WPF applications

Prototype or test with direct access to DBReceive via service tier, offline experience

Service

BusinessComponents

Data Access

SQL

Client

F/S

DataSet

DataSet Binding and Working Offline

Page 10: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 11: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataReader

Rapid, forward-only, read-only cursorUsed for high-performing, customized data access layers, CRUD operationsDatabase support via provider modelMap results to custom typesNo bloat, interoperableNo code gen, third-party tools availableNot used for offline caching

Page 12: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataReader Scenarios

DALCRUD operations with more verbose codeRely on code genCan more easily respond to dynamically changing database structure

Service

BusinessComponents

DALC

SQL

Entities

Mapping

Reader

Data Contracts / Serializable

Data Access Layer with Reader

Page 13: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataReader Scenarios

ASP.NETTwo-way data binding via ObjectDataSourceRequires a data access layer or service proxy

Data Access

SQL

Browser

ASP.NET

Reader

ObjectDataSource

Service

ASP.NET Reader Binding

Page 14: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DataReader Scenarios

Windows Forms and WPF applications

Receive data via service tierOffline support must be customized

Service

BusinessComponents

Data Access

SQL

Client

F/S

Custom Types

DataReader Binding and Working Offline

Page 15: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 16: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET 3.5 Technologies

ADO.NET 3.5.NET Language Integrated Query (LINQ)LINQ features except for LINQ to Entities

ADO.NET 3.5 + SP1Entity Data Model, Entity Framework, Data Services, Object Services, Entity DesignerEntity SQL and LINQ to EntitiesProvider support for SQL 2008 features

Page 17: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ

.NET Language Integrated Query (LINQ)Querying capabilities for many information sources

IEnumerable, IEnumerable<T> or IQueryable<T>Relies on .NET 3.5 language features

Page 18: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ Architecture

Objects

<book> <title/> <author/> <price/></book>

XMLRelational

LINQ enabled data sources

LINQ To Objects

LINQ To XML

LINQ enabled ADO.NET

LINQ To Entities

LINQ To SQL

LINQ To DataSet

.NET Language Integrated Query (LINQ)

Page 19: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ and Relational Data

LINQ to DataSetQuery an ADO.NET DataSet

LINQ to SQLQuery over LINQ to SQL Classes

LINQ to EntitiesQuery over an Entity Data Model

Page 20: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL

RAD/high-performing data access layers, data binding, CRUD operationsGreat for rapid prototyping, code gen with schema-based entitiesLimited support for mapping between storage and entity modelNo bloat, interoperableNo provider model

Page 21: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

BLLLINQ queries against DataContext are wrapped in business layer

Service

BusinessComponents

SQL

LINQ DataContext

Data Contracts / Serializable

LINQEntities

Data Access Layer with LINQ to SQL

Page 22: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

DALLINQ queries against DataContext are wrapped in data access layer

Service

BusinessComponents

SQL

Data Contracts / Serializable

LINQEntities

Data AccessLINQ

DataContext

Data Access Layer with LINQ to SQL

Page 23: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

MappingMap LINQ to SQL entities to custom business objects in the data access layer

Service

BusinessComponents

Data Access

SQL

CustomMapping

LINQ DataContext

Data Contracts / Serializable

LINQEntities

BusinessEntities

Data Access Layer with LINQ to SQL

Page 24: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 25: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

MappingMap LINQ to SQL entities to custom business objects in the data access layerUse a attributes or external XML to control subtle changes to LINQ to SQL entities

Service

BusinessComponents

SQL

Data Contracts / Serializable

LINQEntities

Data AccessLINQ

DataContext

XmlMap

External XML Mapping

Page 26: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

ASP.NETTwo-way data binding via LINQDataSource direct to DataContextTwo-way data binding via ObjectDataSource with a DAL or service proxy

LINQ DataContext

SQL

Browser

ASP.NET

LinqDataSource

LINQEntities

LINQ to SQL Classes

ASP.NET LINQ to SQL Binding

Page 27: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 28: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to SQL Scenarios

Windows Forms and WPF applicationsRAD prototyping and testingReceive via service tierCan customize an offline experience

Page 29: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Entity Framework

Enterprise data access looking for features of an Object/Relational (O/R) MapperEF “is” the DALGreat for rapid prototyping, code gen with schema-based entity mapDesigner support to customize mapping between storage and entity modelNo bloat, interoperable

Page 30: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Entity Framework

Rich provider model including:SQL Server, Oracle, SQL Anywhere, DB2, Informix, U2, PostgresSQL, MySQL, SQLite, Virtuoso, FireBird

Query with ESQL or LINQ to EntitiesSupport for change trackingNotifications have limited use today

Page 31: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

LINQ to Entities Scenarios

BLLLINQ queries against ObjectContext are wrapped in business layer

DALLINQ queries againstObjectContext are wrapped in data access layer

Service

BusinessComponents

Data Access

SQL

Mapping

EFObjectContext

Data Contracts / Serializable

MappingRules

EFEntities

Data Access Layer with Entity Framework

Page 32: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Entity Framework Scenarios

ASP.NETTwo-way data binding via EntityDataSource or ObjectDataSourceEntityDataSource handles some things that you have to do by hand with EF

Specifically, foreign key resolution EF ObjectContext

SQL

Browser

ASP.NET

EntityDataSource

Mapping

MappingRules

EFEntities

ASP.NET Data Binding

Page 33: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Entity Framework Scenarios

Windows Forms and WPF applicationsRAD prototyping and testingReceive via service for n-tier applications

No offline experience todayChange tracking and notifications particularly useful in 2-tier applications

Page 34: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 35: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

O/R Mapper SupportFeature LINQ to SQL Entity Framework

Persistence Ignorance/ POCO

Yes, if you convert collections to List<T>

V1 = No, V2 = Yes

Data Mapper Yes, no designer Yes, designer support

Metadata Mapping Yes Yes

Foreign Key Mapping Yes, via EntitySet<T> and EntityRef<T>

V1 = Independent Associations, V2 = Independent or FK Associations

Association Table Mapping No Yes

Lazy Loading Yes, if you don’t convert to List<T>

V1 = Call Load(), V2 = Yes (DeferredLoadingEnabled)

Eager Loading Yes Yes

Identity Map Yes Yes

Unit of Work Yes Yes

Optimistic Concurrency Yes Yes

Page 36: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET 4.0

Entity Framework V2Persistence ignorance and POCO Improved lazy loadingBetter n-tier distribution and change trackingEntity Designer customizable templatesImproved unit testing and TDD

LINQ to Entities supersedes LINQ to SQLNot obsolete, useful in simple scenarios

Page 37: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET Data Services

RESTful data services based on WCFRelies on HTTP GET, POST, PUT, DELETE verbs to implement APIVery easy to expose any IQueryable data with a fully functional RESTful interfaceUniform pattern for data access regardless of data sourceParticularly useful for exposing data to JavaScript clients

Page 38: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET Data Services

Great for rapid prototyping No-code required to expose LINQ to SQL and Entity Framework modelsIntroduces a service tier on data accessImposes a RESTful web service modelInteroperableLimitations on security model today

Page 39: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET Data Services Scenarios

The data service IS the data access, business and service layerWindows Forms and WPF Clients

No proxy generationCan create your own wrapperSecurity model is limited (today)

ASP.NET AJAX and Silverlight clients can easily build self-navigating UI for a RESTful modelSecure services with web site model

Page 40: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

demo

Page 41: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

ADO.NET Data Services

ADO.NET Data Service

SQL Server

LINQ DataContext LINQ

Entities

REST

ADO.NET Data Service

SQL Server (OR other)

EF ObjectContext EF

Entities

REST

Browser Browser

AJAXSilverlightWindows Forms /

WPF Client

Page 42: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Recommendations

Use DataSet for lightweight offline clientsUse DataReader for more dynamic DBsUse LINQ to SQL for RAD, SQL Server only interaction that doesn’t require extensive mapping to business objectsPrefer Entity Framework for most activities that to gain mapping features, platform alternatives, POCO (future), offline caching and change tracking (future)

Page 43: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Recommendations

Use ADO.NET Data Services for: Building Web UI that focuses on access to resources and drilldown accessBuilding RESTful services that are primarily CRUD-basedRAD prototyping of RESTful data to all clients

Be conscious of:Proxy generation limitations (today)Security model limitations (today)

Page 44: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Resources

Learning WCFMichele Leroux Bustamante, O’Reilly 2007Reprinted with updates for VS2008, August 2008

My Blog: http://www.dasblonde.net

See post-conference blog post forsamples from this and other sessions at Tech Ed!

Book blog: www.thatindigogirl.com

Page 45: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

question & answer

Page 46: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

www.microsoft.com/teched

Sessions On-Demand & Community

http://microsoft.com/technet

Resources for IT Professionals

http://microsoft.com/msdn

Resources for Developers

www.microsoft.com/learningMicrosoft Certification and Training Resources

www.microsoft.com/learning

Microsoft Certification & Training Resources

Resources

Page 47: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

DTL Track Resources

Visit the DPR TLC for a chance to win a copy of Visual Studio Team Suite. Daily drawing occurs every day in the TLC at 4:15pm. Stop by for a raffle ticket

http://www.microsoft.com/visualstudio

http://www.microsoft.com/visualstudio/en-us/products/teamsystem/default.mspx

Please visit us in the TLC blue area

Page 48: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

Complete an evaluation on CommNet and enter to win!

Page 49: Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign:  Microsoft Regional Director,

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.