SlideShare a Scribd company logo
Data Accessjoe.shirey@microsoft.comhttp://www.joeshirey.com
Data Access TechnologiesDataSet/DataReadernHibernateLINQ to SQLEntity FrameworkADO.NET Data Services
Layered ArchitectureUIUIUIDomain ModelBusiness LogicData Access / Persistence LayerDatabase
ClientClientDataSetDataReaderManaged Data ProviderIDataReaderIDbDataAdapterIDbConnectionIDbCommandADO.NET 1.x Architecture
DataSetCRUD based operationsStrongly typed datasetsCan be databoundSupports offline disconnected operations with change trackingRapid prototypingDatabase support via provider modelDifficult object model
DataReaderRapid, forward-only, read-only cursorHigh PerformanceCustomized data access layers, CRUD operationsDatabase support via provider modelMap results to custom typesThird-party tools available for code generationConnected scenarios only
nHibernatePort of the Java Hibernate projectAvailable in .NET 1.1, 2.0, 3.0, 3.5Support of many databasesSQL Server, Oracle, DB2, SQLite, PostgreSQL, MySQL, Firebird, …XML based mapping and configurationLGPL licensedNo designer, LINQ support
ADO.NET 3.5 TechnologiesADO.NET 3.5Language Integrated Query (LINQ)LINQ features except for LINQ to EntitiesADO.NET 3.5 + SP1Entity Framework and the Entity DesignerEntity SQL and LINQ to EntitiesProvider support for SQL 2008 features (extensible)
LINQ Architecture.NET Language Integrated Query (LINQ)LINQ enabled data sourcesLINQ enabled ADO.NETLINQ To XMLLINQ To EntitiesLINQ To SQLLINQ To DataSetLINQ To ObjectsXMLRelationalObjects<book>    <title/>   <author/>    <price/></book>
LINQ to SQLSQL Server only, no provider modelFriendly syntax for mapping tables to objects with full CRUD functionalityHigh performance data access layer with data bindingCode gen with schema-based entitiesLimited support for mapping between storage and entity model (table focused)Designer support
Entity FrameworkMore of a true Object/Relational (O/R) Mapping ToolDesigner Support to create a custom map between data tables and domain modelIs a Data Access LayerSupports code generation with schema-based entity mappingProvider model to support multiple databases
O/R Mapper Support
New in ADO.NET Entity Framework 4.0Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManagercontrolSelf-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integrationCode-Only development (Feature CTP)
DemoEntity Framework 4.0
Multiple Approaches with EF 4.0Start with the database“Database is the truth”Why? It already exists, or you want low level control over the databaseWhat? Import model into EDMX and tweakStart with an EDMX model“EDMXis the truth”Why? You want separation from code and database in a declarative formatWhat? Create a model and tweakStart with .NET classes“Code is the truth”Why? Primarily focused on code shape, database is an implementation detailWhat? Define classes in code, adjust shape using contextbuilder
ADO.NET WCF Data ServicesFormerly called “Astoria”RESTful data services based on WCFRelies on HTTP GET, POST, PUT, DELETE verbs to implement APIVery easy to expose any IQueryable data with a fully functional RESTful interfaceUniform pattern for data access regardless of data sourceParticularly useful for exposing data to JavaScript clients
OData: Open Data ProtocolOData ConsumersOData ProducersOData Protocol.NET FrameworkExcel/PowerPivotSharepointVisual StudioSharepoint Services.NET FrameworkSQL Server Reporting ServicesSilverlightWindows Azure Table StorageJavascript/AJAXCodename “Dallas”PHPJavaODGI

More Related Content

Microsoft Data Access Technologies

  • 2. Data Access TechnologiesDataSet/DataReadernHibernateLINQ to SQLEntity FrameworkADO.NET Data Services
  • 3. Layered ArchitectureUIUIUIDomain ModelBusiness LogicData Access / Persistence LayerDatabase
  • 5. DataSetCRUD based operationsStrongly typed datasetsCan be databoundSupports offline disconnected operations with change trackingRapid prototypingDatabase support via provider modelDifficult object model
  • 6. DataReaderRapid, forward-only, read-only cursorHigh PerformanceCustomized data access layers, CRUD operationsDatabase support via provider modelMap results to custom typesThird-party tools available for code generationConnected scenarios only
  • 7. nHibernatePort of the Java Hibernate projectAvailable in .NET 1.1, 2.0, 3.0, 3.5Support of many databasesSQL Server, Oracle, DB2, SQLite, PostgreSQL, MySQL, Firebird, …XML based mapping and configurationLGPL licensedNo designer, LINQ support
  • 8. ADO.NET 3.5 TechnologiesADO.NET 3.5Language Integrated Query (LINQ)LINQ features except for LINQ to EntitiesADO.NET 3.5 + SP1Entity Framework and the Entity DesignerEntity SQL and LINQ to EntitiesProvider support for SQL 2008 features (extensible)
  • 9. LINQ Architecture.NET Language Integrated Query (LINQ)LINQ enabled data sourcesLINQ enabled ADO.NETLINQ To XMLLINQ To EntitiesLINQ To SQLLINQ To DataSetLINQ To ObjectsXMLRelationalObjects<book> <title/> <author/> <price/></book>
  • 10. LINQ to SQLSQL Server only, no provider modelFriendly syntax for mapping tables to objects with full CRUD functionalityHigh performance data access layer with data bindingCode gen with schema-based entitiesLimited support for mapping between storage and entity model (table focused)Designer support
  • 11. Entity FrameworkMore of a true Object/Relational (O/R) Mapping ToolDesigner Support to create a custom map between data tables and domain modelIs a Data Access LayerSupports code generation with schema-based entity mappingProvider model to support multiple databases
  • 13. New in ADO.NET Entity Framework 4.0Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManagercontrolSelf-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integrationCode-Only development (Feature CTP)
  • 15. Multiple Approaches with EF 4.0Start with the database“Database is the truth”Why? It already exists, or you want low level control over the databaseWhat? Import model into EDMX and tweakStart with an EDMX model“EDMXis the truth”Why? You want separation from code and database in a declarative formatWhat? Create a model and tweakStart with .NET classes“Code is the truth”Why? Primarily focused on code shape, database is an implementation detailWhat? Define classes in code, adjust shape using contextbuilder
  • 16. ADO.NET WCF Data ServicesFormerly called “Astoria”RESTful data services based on WCFRelies on HTTP GET, POST, PUT, DELETE verbs to implement APIVery easy to expose any IQueryable data with a fully functional RESTful interfaceUniform pattern for data access regardless of data sourceParticularly useful for exposing data to JavaScript clients
  • 17. OData: Open Data ProtocolOData ConsumersOData ProducersOData Protocol.NET FrameworkExcel/PowerPivotSharepointVisual StudioSharepoint Services.NET FrameworkSQL Server Reporting ServicesSilverlightWindows Azure Table StorageJavascript/AJAXCodename “Dallas”PHPJavaODGI
  • 18. RecommendationsLINQ to SQLSQL Server only scenariosSimple table to object mappingsnHibernatePre .NET 3.5 limitations.NET 3.5 SP1 complex table/object mappingsDatabase support beyond SQL ServerEntity Framework3.5 SP1 with moderate table/object mappings4.0 scenariosPOCO mappings desiredOffline and change tracking
  • 19. RecommendationsWCF Data ServicesAccess to data primarily not methodsWrapping EF for standard data accessRESTful services that mainly CRUD basedProtect against future changesSupport for both web and RIA applications