300 likes | 422 Views
Advances for Data in VS “Orcas”. Mike Taulty Developer & Platform Group Microsoft Ltd Mike.Taulty@microsoft.com http://www.mtaulty.com. Earlier that day. Object. Object. Object. Object. from itemName in srcExpr join itemName in srcExpr on keyExpr equals keyExpr ( into itemName ) ?
E N D
Advances for Data in VS “Orcas” Mike Taulty Developer & Platform Group Microsoft Ltd Mike.Taulty@microsoft.com http://www.mtaulty.com
Earlier that day.... Object Object Object Object fromitemNameinsrcExpr join itemNameinsrcExpronkeyExprequalskeyExpr (intoitemName)? letitemName= selExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr group selExprbykeyExpr intoitemName query-body
IEnumerable<T>? Object fromitemNameinsrcExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr ... Object Object Object Object Object where Object Object orderby Object select
IQueryable<T>? Object fromitemNameinsrcExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr ... Object Object Object where where where orderby orderby Object Object Object Object Object select
LINQ over XML 1 LINQ Pattern fromitemNameinsrcExpr join itemNameinsrcExpronkeyExprequalskeyExpr (intoitemName)? letitemName= selExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr group selExprbykeyExpr intoitemName query-body New XML API
System.Xml.XLinq • New XML API (more DOM than reader) • Key classes: XElement, XAttribute
LINQ to SQL 2 LINQ Pattern fromitemNameinsrcExpr join itemNameinsrcExpronkeyExprequalskeyExpr (intoitemName)? letitemName= selExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr group selExprbykeyExpr intoitemName query-body Object Relational Mapping API Code Gen Tools
But what about? • Identity • Relationships • Insert, Update, Delete • Constraints • Generated columns • Transactions • Stored Procedures, Views, Functions • Deferred Loading • Inheritance • Concurrency • Modifications without query • e.g. N-Tier updates
Identity Management My Process Query Id=58 Update Id=58, Colour=Blue Query Id=58 Identity Management Object Id=58, Colour = Red Object Id=58, Colour = Blue Original Current SQL Row ID = 58, Colour=Red
Change Tracking (1) My Process DataContext.SubmitChanges() Change Tracking Object Id=58, Colour = Red Object Id=58, Colour = Blue Original Current Compare & Generate SQL SQL
Change Tracking (2) My Process Update Id=58, Colour=Blue Fire Property Changed Notification! Change Tracking Object Id=58, Colour = Red Object Id=58, Colour = Blue Original Current SQL
Change Tracking (3) My Process DataContext.SubmitChanges() Change Tracking Object Id=58, Colour = Blue Current Generate SQL from List of Changes SQL
LINQ to DataSet 3 LINQ Pattern fromitemNameinsrcExpr join itemNameinsrcExpronkeyExprequalskeyExpr (intoitemName)? letitemName= selExpr wherepredExpr orderby(keyExpr(ascending| descending)?)* selectselExpr group selExprbykeyExpr intoitemName query-body Jo John Jim FirstName Fred Blogs LastName Doe Smith Jones 22 43 55 Age 17 1.3 1.2 1.4 Height 1.5 DataSet/DataTable
Linq to DataSet • Existing DataTable already has some query capabilities • LINQ syntax extends to DataSet to apply the same model for querying
Awareness: ADO.NET Entity Framework
Conceptual Models Conceptual Design (Entities & Relationships) Customer Order Application (Entities & Relationships) places SalesPerson sells
Relational Models relational schema (normalised, tables, keys) Application (Entities & Relationships) SP's SP's SP's Mapping Logic Conceptual<->Relational Mapping Logic Conceptual<->Relational Mapping Logic Conceptual<->Relational Views Views Views Fn's Fn's Fn's Application (Entities & Relationships) Application (Entities & Relationships)
ADO.NET Entity Framework Application (Entities & Relationships) LINQ Syntax Entity SQL Conceptual Schema (XML) Store Schema (XML) ADO.NET Mapping Provider Mapping Schema (XML) Object Services (Inheritance & Complex Types) SQL ADO.NET Database Provider (e.g. SqlProvider)
Do Try This At Home But... • This Talk Was Brought To You By; • The LINQ May CTP • The ADO.NET V.Next August CTP • Concepts have not changed • Later CTPs have slightly altered syntax • My CTP lacked IntelliSense • In the later builds
Summary • Powerful, intuitive LINQ pattern • One "syntax" to learn • Relational, hierarchical, object data • Underpinned by new or existing API's • For Relational Data • LINQ to SQL • ORM over database schema • LINQ to Entities and the Entity Framework • ORM over conceptual model