The Microsoft
Technical Roadshow 2007
Advances for Data in VS “Orcas”
Mike TaultyDeveloper & Platform GroupMicrosoft [email protected] http://www.mtaulty.com
Earlier that day....
ObjectObject
ObjectObject
from itemName in srcExpr join itemName in srcExpr on keyExpr equals keyExpr
(into itemName)?let itemName = selExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExprgroup selExpr by keyExpr into itemName query-body
IEnumerable<T>?
ObjectObject
ObjectObject
from itemName in srcExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExpr...
where ObjectObject
ObjectObjectorderby
select Object
IQueryable<T>?
ObjectObject
ObjectObject
from itemName in srcExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExpr...
where
whereorderby
whereorderby
select
ObjectObject
ObjectObject
Object
IEnumerable vs IQueryable
Agenda”Would you like LINQ with that?”
LINQ
Objects
XML SQL
DataSet
1 2
3
LINQ Pattern from itemName in srcExpr join itemName in srcExpr on keyExpr equals keyExpr
(into itemName)?let itemName = selExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExprgroup selExpr by keyExpr into itemName query-body
New XML API
LINQ over XML1
System.Xml.XLinq
New XML API (more DOM than reader)Key classes: XElement, XAttribute
LINQ over XML
LINQ Pattern from itemName in srcExpr join itemName in srcExpr on keyExpr equals keyExpr
(into itemName)?let itemName = selExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExprgroup selExpr by keyExpr into itemName query-body
Object Relational Mapping API
Code Gen Tools
LINQ to SQL2
System.Data.Dlinq – Data API
DataContext, Table & Friends
But what about?
IdentityRelationshipsInsert, Update, DeleteConstraintsGenerated columnsTransactions
Stored Procedures, Views, FunctionsDeferred LoadingInheritanceConcurrencyModifications without query
e.g. N-Tier updates
More detail but no updates yet...
Identity Management
SQL
My Process
Identity Management
Row ID = 58, Colour=Red
Query Id=58
UpdateId=58,
Colour=Blue
QueryId=58
ObjectId=58,
Colour = Red OriginalObjectId=58,
Colour = Blue Current
Change Tracking (1)
SQL
DataContext.SubmitChanges()
Compare & Generate SQL
My Process
Change TrackingObjectId=58,
Colour = Red OriginalObjectId=58,
Colour = Blue Current
Change Tracking (2)
SQL
My Process
Change Tracking
UpdateId=58,
Colour=Blue
ObjectId=58,
Colour = Red OriginalObjectId=58,
Colour = Blue Current
Fire PropertyChanged
Notification!
Change Tracking (3)
SQL
DataContext.SubmitChanges()
My Process
Change TrackingObjectId=58,
Colour = Blue Current
Generate SQL from List of Changes
Updates, Transactions...
FirstName LastName Age Height
Fred Smith 55 1.2
Jim Jones 22 1.3
John Doe 43 1.4
Jo Blogs 17 1.5
LINQ Pattern from itemName in srcExpr join itemName in srcExpr on keyExpr equals keyExpr
(into itemName)?let itemName = selExprwhere predExprorderby (keyExpr (ascending | descending)?)*select selExprgroup selExpr by keyExpr into itemName query-body
DataSet/DataTable
LINQ to DataSet3
Linq to DataSet
Existing DataTable already has some query capabilities
LINQ syntax extends to DataSet to apply the same model for querying
LINQ to DataSet
Putting a few things together
Awareness:ADO.NET Entity Framework
Conceptual Models
Conceptual Design(Entities & Relationships)
Customer Order
SalesPerson
places
sells
Application(Entities & Relationships)
Relational Models
Application(Entities & Relationships)
relational schema(normalised, tables, keys)
SP's
Views
Fn's
Mapping LogicConceptual<->Relational
Application(Entities & Relationships)
SP's
Views
Fn's
Mapping LogicConceptual<->Relational
Application(Entities & Relationships)
SP's
Views
Fn's
Mapping LogicConceptual<->Relational
ADO.NETMapping Provider
Entity SQL
Object Services(Inheritance & Complex Types)
ADO.NETDatabase Provider(e.g. SqlProvider)
SQL
Application(Entities & Relationships)
LINQ Syntax
ConceptualSchema(XML)
MappingSchema(XML)
StoreSchema(XML)
ADO.NET Entity Framework
Do Try This At Home But...
This Talk Was Brought To You By;
The LINQ May CTPThe ADO.NET V.Next August CTP
Concepts have not changedLater CTPs have slightly altered syntaxMy CTP lacked IntelliSense
In the later builds
Summary
Powerful, intuitive LINQ patternOne "syntax" to learnRelational, hierarchical, object dataUnderpinned by new or existing API's
For Relational DataLINQ to SQL
– ORM over database schema
LINQ to Entities and the Entity Framework– ORM over conceptual model
© 2007 Microsoft Ltd. 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.
roadshowresources.com