Microsoft Data Access Technologies


Published on

Joe Shirey's deck delivered at 2009Q4 Microosft Architect Council events

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Microsoft Data Access Technologies

  1. 1. Data Access<br /><br /><br />
  2. 2. Data Access Technologies<br />DataSet/DataReader<br />nHibernate<br />LINQ to SQL<br />Entity Framework<br />ADO.NET Data Services<br />
  3. 3. Layered Architecture<br />UI<br />UI<br />UI<br />Domain Model<br />Business Logic<br />Data Access / Persistence Layer<br />Database<br />
  4. 4. Client<br />Client<br />DataSet<br />DataReader<br />Managed <br />Data <br />Provider<br />IDataReader<br />IDbDataAdapter<br />IDbConnection<br />IDbCommand<br />ADO.NET 1.x Architecture<br />
  5. 5. DataSet<br />CRUD based operations<br />Strongly typed datasets<br />Can be databound<br />Supports offline disconnected operations with change tracking<br />Rapid prototyping<br />Database support via provider model<br />Difficult object model<br />
  6. 6. DataReader<br />Rapid, forward-only, read-only cursor<br />High Performance<br />Customized data access layers, CRUD operations<br />Database support via provider model<br />Map results to custom types<br />Third-party tools available for code generation<br />Connected scenarios only<br />
  7. 7. nHibernate<br />Port of the Java Hibernate project<br />Available in .NET 1.1, 2.0, 3.0, 3.5<br />Support of many databases<br />SQL Server, Oracle, DB2, SQLite, PostgreSQL, MySQL, Firebird, …<br />XML based mapping and configuration<br />LGPL licensed<br />No designer, LINQ support<br />
  8. 8. ADO.NET 3.5 Technologies<br />ADO.NET 3.5<br />Language Integrated Query (LINQ)<br />LINQ features except for LINQ to Entities<br />ADO.NET 3.5 + SP1<br />Entity Framework and the Entity Designer<br />Entity SQL and LINQ to Entities<br />Provider support for SQL 2008 features (extensible)<br />
  9. 9. LINQ Architecture<br />.NET Language Integrated Query (LINQ)<br />LINQ enabled data sources<br />LINQ enabled ADO.NET<br />LINQ <br />To XML<br />LINQ <br />To Entities<br />LINQ <br />To SQL<br />LINQ <br />To DataSet<br />LINQ <br />To Objects<br />XML<br />Relational<br />Objects<br />&lt;book&gt;<br /> &lt;title/&gt;<br /> &lt;author/&gt;<br /> &lt;price/&gt;<br />&lt;/book&gt;<br />
  10. 10. LINQ to SQL<br />SQL Server only, no provider model<br />Friendly syntax for mapping tables to objects with full CRUD functionality<br />High performance data access layer with data binding<br />Code gen with schema-based entities<br />Limited support for mapping between storage and entity model (table focused)<br />Designer support<br />
  11. 11. Entity Framework<br />More of a true Object/Relational (O/R) Mapping Tool<br />Designer Support to create a custom map between data tables and domain model<br />Is a Data Access Layer<br />Supports code generation with schema-based entity mapping<br />Provider model to support multiple databases<br />
  12. 12. O/R Mapper Support<br />
  13. 13. New in ADO.NET Entity Framework 4.0<br />Model-first development<br />Automatic pluralization<br />Foreign keys in models<br />POCO class support<br />Lazy loading<br />T4 Code Generation<br />Template customization<br />IObjectSet<br />Virtual SaveChanges<br />ObjectStateManagercontrol<br />Self-tracking entities<br />SQL generation improvements<br />More LINQ operator support<br />LINQ extensibility<br />ExecuteStoreQuery<br />ExecuteStoreCommand<br />SPROC import improvements<br />Model defined functions<br />WPF designer integration<br />Code-Only development (Feature CTP)<br />
  14. 14. DemoEntity Framework 4.0<br />
  15. 15. Multiple Approaches with EF 4.0<br />Start with the database<br />“Database is the truth”<br />Why? It already exists, or you want low level control over the database<br />What? Import model into EDMX and tweak<br />Start with an EDMX model<br />“EDMXis the truth”<br />Why? You want separation from code and database in a declarative format<br />What? Create a model and tweak<br />Start with .NET classes<br />“Code is the truth”<br />Why? Primarily focused on code shape, database is an implementation detail<br />What? Define classes in code, adjust shape using contextbuilder<br />
  16. 16. ADO.NET WCF Data Services<br />Formerly called “Astoria”<br />RESTful data services based on WCF<br />Relies on HTTP GET, POST, PUT, DELETE verbs to implement API<br />Very easy to expose any IQueryable data with a fully functional RESTful interface<br />Uniform pattern for data access regardless of data source<br />Particularly useful for exposing data to JavaScript clients <br />
  17. 17. OData: Open Data Protocol<br />OData Consumers<br />OData Producers<br />OData Protocol<br />.NET Framework<br />Excel/PowerPivot<br />Sharepoint<br />Visual Studio<br />Sharepoint Services<br />.NET Framework<br />SQL Server Reporting Services<br />Silverlight<br />Windows Azure Table Storage<br />Javascript/AJAX<br />Codename “Dallas”<br />PHP<br />Java<br />ODGI<br />
  18. 18. Recommendations<br />LINQ to SQL<br />SQL Server only scenarios<br />Simple table to object mappings<br />nHibernate<br />Pre .NET 3.5 limitations<br />.NET 3.5 SP1 complex table/object mappings<br />Database support beyond SQL Server<br />Entity Framework<br />3.5 SP1 with moderate table/object mappings<br />4.0 scenarios<br />POCO mappings desired<br />Offline and change tracking<br />
  19. 19. Recommendations<br />WCF Data Services<br />Access to data primarily not methods<br />Wrapping EF for standard data access<br />RESTful services that mainly CRUD based<br />Protect against future changes<br />Support for both web and RIA applications<br />
  20. 20. Data Access<br /><br /><br />