+ All Categories
Home > Technology > LINQ to Relational in Visual Studio 2008 SP1

LINQ to Relational in Visual Studio 2008 SP1

Date post: 10-May-2015
Category:
Upload: ukdpe
View: 1,212 times
Download: 1 times
Share this document with a friend
Description:
LINQ to Relational in VS 2008 Sp1
Popular Tags:
16
1 LINQ to “Relational” (L2R) in Visual Studio 2008 SP 1 Mike Taulty Developer & Platform Group Microsoft Ltd [email protected] http://www.miketaulty.com
Transcript
Page 1: LINQ to Relational in Visual Studio 2008 SP1

1

LINQ to “Relational” (L2R) inVisual Studio 2008 SP 1

Mike TaultyDeveloper & Platform GroupMicrosoft [email protected] http://www.miketaulty.com

Page 2: LINQ to Relational in Visual Studio 2008 SP1

Where Are We?

Page 3: LINQ to Relational in Visual Studio 2008 SP1

“Traditional” ADO.NET Data Access

App CodeApp Code

Customers

ADO.NETADO.NET

DataReaderDataReader

Customers

CommandCommand

““SELECT * SELECT * FROM CUSTOMERS”FROM CUSTOMERS”

DataSetDataSet

Page 4: LINQ to Relational in Visual Studio 2008 SP1

“Traditional” ADO.NET Data AccessApp CodeApp Code

Customers

ADO.NETADO.NETLayerLayer

DataReaderDataReader

Customers

CommandCommand

““SELECT * SELECT * FROM CUSTOMERS”FROM CUSTOMERS”

DataDataObjectObject

Load()Load()

CustomerCustomer

FirstNamFirstNameeLastNamLastNamee

......

CustomerCustomer

FirstNamFirstNameeLastNamLastNamee

......

CustomerCustomer

FirstNamFirstNameeLastNamLastNamee

......

CustomerCustomer

FirstNamFirstNameeLastNamLastNamee

......

ORMORM

Page 5: LINQ to Relational in Visual Studio 2008 SP1

Language Integrated Queryfrom data in someDataSourcejoin otherData in someOtherSource on keyExpr equals keyExpr (into itemName)?let someVariable = someExpressionwhere somePredicateorderby (expression (ascending | descending)?)*select expressiongroup expression by keyExpression into itemName

.NET Framework V3.5 Service Pack 1.NET Framework V3.5 Service Pack 1

Language Features ( C# V3 and VB V9 )Language Features ( C# V3 and VB V9 )

CustoCustomm

ObjeObjectscts XMLXML SQLSQL EntitiEntiti

eses

Page 6: LINQ to Relational in Visual Studio 2008 SP1

6

LINQ is not just relational

Page 7: LINQ to Relational in Visual Studio 2008 SP1

Two Different Styles of LINQ from data in someDataSourcejoin otherData in someOtherSource on keyExpr equals keyExpr (into itemName)?let someVariable = someExpressionwhere somePredicateorderby (expression (ascending | descending)?)*select expressiongroup expression by keyExpression into itemName

IEnumerable<TIEnumerable<T>>

IQueryable<T>IQueryable<T>

Page 8: LINQ to Relational in Visual Studio 2008 SP1

8

IEnumerable/IQueryable

Page 9: LINQ to Relational in Visual Studio 2008 SP1

LINQ is about Query

LINQ specifies a standard syntax for querying dataLINQ has no standard syntax for modifying dataDifferent API’s take a different approach

LINQ to Objects has no approach – unneccessaryLINQ to XMLLINQ to SQLLINQ to Entities

Page 10: LINQ to Relational in Visual Studio 2008 SP1

LINQ to Relational ( “L2R” )

LINQ to SQL.NET Framework V3.5SQL Server databases – 2000, 2005, 2008 & CEUses existing ADO.NET SQL Provider

ADO.NET Entity Framework (“LINQ to Entities”).NET Framework V3.5 Service Pack 1Database agnosticNeeds modified ADO.NET Providers

Microsoft ships SQL and example Oracle providerVarious 3rd party providers in progress

Page 11: LINQ to Relational in Visual Studio 2008 SP1

L2R – Commonality in Querying

App CodeApp Code

Customers

““LINQ”LINQ”

QueryableQueryableObjectObject

DataReaderDataReader

Customers

LINQLINQQueryQuery

CallCall

ExecuteExecute

ContextContext

GetQueryable<TGetQueryable<T>()>()

Execute<T>()Execute<T>()

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

Materialise objectsMaterialise objects

ADO.NETADO.NETProviderProvider

Translate to Translate to SQLSQL

ORMMetadata

CreateCreate

Page 12: LINQ to Relational in Visual Studio 2008 SP1

L2R – Commonality in Modifying

App CodeApp Code

Customers

““LINQ”LINQ”

ContextContext

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

CustomeCustomerrFirstNamFirstNam

eeLastNamLastNamee

......

““Create”<T>()Create”<T>()

““Delete”<T>Delete”<T>

SaveChanges()SaveChanges()

CreateCreate

DeleteDelete

UpdatUpdatee

StateState

Del Del DelIns Upd

SaveSaveADO.NETADO.NETProviderProvider

Translate to Translate to SQLSQL

ORMMetadata

Page 13: LINQ to Relational in Visual Studio 2008 SP1

L2R - Differences

Page 14: LINQ to Relational in Visual Studio 2008 SP1

14

LINQ to Relational

Page 15: LINQ to Relational in Visual Studio 2008 SP1

Resources

Page 16: LINQ to Relational in Visual Studio 2008 SP1

© 2008 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.


Recommended