Presentation is loading. Please wait.

Presentation is loading. Please wait.

2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK

Similar presentations


Presentation on theme: "2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK"— Presentation transcript:

1

2 2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK http://blogs.msdn.com/ericnel

3 3 Agenda Data Access Overview Data access over the years ORM anyone? LINQ and LINQ to SQL ADO.NET Entity Framework Drill into Entity Framework LINQ to Entities LINQ to SQL vs LINQ to Entities Using Entity Framework with ASP.NET Traditional ASP.NET ASP.NET Dynamic Data

4 4 Data Access over the years Accessing data in 1990 ODBC, embedded SQL Accessing data in 2000 ADO, Stored Procedures Accessing data in 2005 ADO.NET, Datasets, DataReaders Accessing data in 2010 ORM baby!

5 5 Sidebar: Object Relational Mapping What is it? – technique for working with relational tables as if they were objects in memory – Intention is to hide away the complexity of the underlying tables and give a uniform way of working with data Why use it? – Productivity – Retain database independence Notes – There are many ORMs for.NET developers already in existence. E.g. – LLBLGen Pro http://www.llblgen.com/http://www.llblgen.com/ – Nhibernate http://www.hibernate.org/343.htmlhttp://www.hibernate.org/343.html – EntitySpaces http://www.entityspaces.net/Portal/Default.aspxhttp://www.entityspaces.net/Portal/Default.aspx

6 6 How did we get here? ObjectSpaces “v1” – never shipped ObjectSpaces “v2” – never shipped Microsoft Business Framework – never shipped WinFS – never shipped LINQ to SQL - shipped November 2007 LINQ to Entities - shipped August 2008

7 7 A bit like buses Not one but two ORMs LINQ to SQL LINQ to Entities

8 8 LINQ and LINQ to SQL What is it? – LINQ is not about databases, it is about objects – LINQ = Language-Integrated Query – Extensions to programming languages to query objects in memory – LINQ to SQL is not about databases, it is about SQL Server Why use it? – Productivity!!! Notes – We ship in.NET Framework 3.5 – LINQ to Objects – LINQ to XML – LINQ to Datasets – LINQ to SQL – LINQ to Entities – added in.NET Framework 3.5 SP1 – Others make LINQ to Flickr etc – www.linqpad.net www.linqpad.net

9 9 Some simple LINQ

10 10 ADO.NET Entity Framework What is it? – Provides tools and services to create an Entity Data Model – Maps entities to database tables – Provides tools and services for working with an Entity Data Model – Includes ORM capabilities Why use it? – Productivity – Work with SQL Server, Oracle, DB2 etc – When require complex mapping between entities and database tables – Strategic – Works great with ADO.NET Data Services Notes – Just released!

11 11 Drill into ADO.NET Entity Framework Mapping conceptual to physical Demo Entity Data Model Traditional querying Entity Client Object based access Demo Object Services

12 Sidebar: LINQ to SQL vs LINQ to Entities 1/2 It depends... LINQ to SQLLINQ to Entities Database SupportSQL ServerMany Object Relational Mapping Capabilities SimpleComplex Requires Attributed.NET Code NoYes StatusReleasedJust Released

13 Sidebar: Similar – but not quite 2/2 LINQ to SQL – var products = from prod in db.Product – where prod.Color == "Blue" – select prod; LINQ to Entities – var products = from prod in db.Product – where prod.Color == "Blue" – select prod; In general – LINQ to Entities does more – but not always! Only migration that will ever happen is LINQ to SQL migration to LINQ to Entities

14 14 Entity Data Model Application model – Mapped to a persistence store Comprised of three layers: – Conceptual (CSDL) – Mapping (MSL) – Storage (SSDL) Database agnostic Comprised of: – Entities – Associations – Functions Conceptual Mapping Storage Entity Data Model

15 15 Creating the Entity Data Model

16 16 Entity Framework EDM consumption options: – Entity Client – Entity SQL – Object Services – Entity SQL – LINQ To Entities

17 17 Entity Client Familiar ADO.NET object model: – EntityCommand – EntityConnection – EntityDataReader – Entity Parameter – EntityTransaction Text-based results Read-only Uses Entity SQL

18 18 Object Services Queries materialized as Objects – ObjectContext – ObjectQuery Built on top of Entity Client Two query options: – Entity SQL – LINQ Runtime services: – Unit of work – Identity tracking – Eager/explicit loading

19 19 Entity Framework – Service Stack LINQ To Entities Object Services Entity SQL Entity Client ADO.NET Provider

20 20 Using LINQ to Entities

21 21 Using Entity Framework with ASP.NET New Entity Data Source Traditional ASP.NET Rich web site scaffolding Works with LINQ to SQL and LINQ to Entities ASP.NET Dynamic Data

22 22 ASP.NET and Entity Framework

23 23 The future? Across MS Products and Technologies E.g. Reporting Services? Entity Framework more widely adopted Better ORM capabilities in LINQ to Entities POCO support Rough edges removed Developed “in isolation” e.g. ASP.NET Dynamic Data and Entity Framework Technologies work better together Less xml editing during development Better tooling

24 24 Conclusion Data Access technology remained reasonably static Procedural, API access Surfaced the database schema 1990 to 2007 - Tables LINQ – excellent addition to the.NET languages Entity Framework and the EDM – strategic investment Productivity leap 2008 - Objects Plenty more to come 2009

25 25 Resources http:// blogs.msdn.com/ericnel http:// blogs.msdn.com/ericnel - all the links General – ADO.NET Team Blog http://blogs.msdn.com/adonethttp://blogs.msdn.com/adonet – Mike in our team http://www.miketaulty.com ( search Entity or LINQ )http://www.miketaulty.com – Data Platform Developer Centre http://msdn.microsoft.com/en- gb/data/default.aspxhttp://msdn.microsoft.com/en- gb/data/default.aspx LINQ – LINQPad http://www.linqpad.net/http://www.linqpad.net/ ADO.NET Entity Framework – EF Lead PM http://blogs.msdn.com/dsimmonshttp://blogs.msdn.com/dsimmons – FAQ http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspxhttp://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx – Entity Framework Design http://blogs.msdn.com/efdesign/default.aspxhttp://blogs.msdn.com/efdesign/default.aspx ADO.NET Data Services – Team blog http://blogs.msdn.com/astoriateamhttp://blogs.msdn.com/astoriateam

26 26 Acronyms EDM = Entity Data ModelEF = ADO.NET Entity FrameworkESQL = Entity SQLLINQ = Language Integrated QueryCSDL = Conceptual Schema Definition LanguageSSDL = Store Schema Definition LanguageMSDL = Mapping Schema Definition LanguageLambda Syntax = customer.Select(...)Comprehension Syntax = from c in customer...SQL = Structured Query Language

27 27 Resources www.microsoft.com/teched Tech·TalksTech·Ed Bloggers Live SimulcastsVirtual Labs http://msdn.microsoft.com Developer’s Kit, Licenses, and MORE! http://microsoft.com/expression Professional Design tools for tomorrow

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


Download ppt "2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK"

Similar presentations


Ads by Google