LINQ to “Relational” (L2R) in Visual Studio 2008 SP 1 Mike Taulty Developer & Platform Group Microsoft Ltd [email_address]   http://www.miketaulty.com
Where Are We?
“ Traditional” ADO.NET Data Access App Code Customers ADO.NET DataReader Customers Command “ SELECT *  FROM CUSTOMERS” DataSet
“ Traditional” ADO.NET Data Access App Code Customers ADO.NET Layer DataReader Customers Command “ SELECT *  FROM CUSTOMERS” Data Object Load() Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... ORM
Language  Integrated  Query from   data   in   someDataSource join   otherData   in   someOtherSource   on   keyExpr   equals   keyExpr  ( into   itemName )? let   someVariable   =  someExpression where somePredicate orderby   ( expression   ( ascending  |  descending )?)* select   expression group   expression   by   keyExpression   into   itemName   .NET Framework V3.5 Service Pack 1 Language Features ( C# V3 and VB V9 ) Custom Objects XML SQL Entities
LINQ is  not  just relational
Two Different Styles of LINQ  from   data   in   someDataSource join   otherData   in   someOtherSource   on   keyExpr   equals   keyExpr  ( into   itemName )? let   someVariable   =  someExpression where somePredicate orderby   ( expression   ( ascending  |  descending )?)* select   expression group   expression   by   keyExpression   into   itemName   IEnumerable<T> IQueryable<T>
IEnumerable/IQueryable
LIN Q  is about  Query LINQ specifies a standard syntax for  querying  data LINQ has no standard syntax for  modifying  data Different API’s take a different approach LINQ to Objects has  no approach – unneccessary LINQ to XML LINQ to SQL LINQ to Entities
LINQ to Relational ( “L2R” ) LINQ to SQL .NET Framework V3.5 SQL Server databases – 2000, 2005, 2008 & CE Uses existing ADO.NET SQL Provider ADO.NET Entity Framework (“LINQ to Entities”) .NET Framework V3.5 Service Pack 1 Database agnostic Needs modified ADO.NET Providers Microsoft ships SQL and example Oracle provider Various 3 rd  party providers in progress
L2R  – Commonality in Querying App Code Customers “ LINQ” Queryable Object DataReader Customers LINQ Query Call Execute Context GetQueryable<T>() Execute<T>() Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... Materialise objects ADO.NET Provider Translate to SQL ORM Metadata Create
L2R  – Commonality in Modifying App Code Customers “ LINQ” Context Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... “ Create”<T>() “ Delete”<T> SaveChanges() Create Delete Update State Del Del Del Ins Upd Save ADO.NET Provider Translate to SQL ORM Metadata
L2R - Differences
LINQ to Relational
Resources
© 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.

LINQ to Relational in Visual Studio 2008 SP1

  • 1.
    LINQ to “Relational”(L2R) in Visual Studio 2008 SP 1 Mike Taulty Developer & Platform Group Microsoft Ltd [email_address] http://www.miketaulty.com
  • 2.
  • 3.
    “ Traditional” ADO.NETData Access App Code Customers ADO.NET DataReader Customers Command “ SELECT * FROM CUSTOMERS” DataSet
  • 4.
    “ Traditional” ADO.NETData Access App Code Customers ADO.NET Layer DataReader Customers Command “ SELECT * FROM CUSTOMERS” Data Object Load() Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... ORM
  • 5.
    Language Integrated Query from data in someDataSource join otherData in someOtherSource on keyExpr equals keyExpr ( into itemName )? let someVariable = someExpression where somePredicate orderby ( expression ( ascending | descending )?)* select expression group expression by keyExpression   into itemName .NET Framework V3.5 Service Pack 1 Language Features ( C# V3 and VB V9 ) Custom Objects XML SQL Entities
  • 6.
    LINQ is not just relational
  • 7.
    Two Different Stylesof LINQ from data in someDataSource join otherData in someOtherSource on keyExpr equals keyExpr ( into itemName )? let someVariable = someExpression where somePredicate orderby ( expression ( ascending | descending )?)* select expression group expression by keyExpression   into itemName IEnumerable<T> IQueryable<T>
  • 8.
  • 9.
    LIN Q is about Query LINQ specifies a standard syntax for querying data LINQ has no standard syntax for modifying data Different API’s take a different approach LINQ to Objects has no approach – unneccessary LINQ to XML LINQ to SQL LINQ to Entities
  • 10.
    LINQ to Relational( “L2R” ) LINQ to SQL .NET Framework V3.5 SQL Server databases – 2000, 2005, 2008 & CE Uses existing ADO.NET SQL Provider ADO.NET Entity Framework (“LINQ to Entities”) .NET Framework V3.5 Service Pack 1 Database agnostic Needs modified ADO.NET Providers Microsoft ships SQL and example Oracle provider Various 3 rd party providers in progress
  • 11.
    L2R –Commonality in Querying App Code Customers “ LINQ” Queryable Object DataReader Customers LINQ Query Call Execute Context GetQueryable<T>() Execute<T>() Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... Materialise objects ADO.NET Provider Translate to SQL ORM Metadata Create
  • 12.
    L2R –Commonality in Modifying App Code Customers “ LINQ” Context Customer FirstName LastName ... Customer FirstName LastName ... Customer FirstName LastName ... “ Create”<T>() “ Delete”<T> SaveChanges() Create Delete Update State Del Del Del Ins Upd Save ADO.NET Provider Translate to SQL ORM Metadata
  • 13.
  • 14.
  • 15.
  • 16.
    © 2008 MicrosoftCorporation. 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.

Editor's Notes

  • #2 06/07/09 01:40 © 2007 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.