MSDN Magazine - July 2008 - (Page 75) primary scenarios. These include the use of ADO.NET Data Services or the use of Windows® Communication Foundation (WCF) with the ability to serialize entities and attach and detach entities from an ObjectContext. These are obviously not the only approaches to n-tier development; however, these are the solutions the team chose to concentrate on in V1, with additional scenarios added in V2 and beyond, such as a more dataset-like experience. Figure 9 illustrates what I’m talking about. ADO.NET Data Services is a concrete realization of a Representational State Transfer (REST) architecture style (each resource represents a “noun” in the system—a thing that can be uniquely addressed via a Uniform Resource Identifier, or URI), which enables n-tier application development over any arbitrary IQueryable implementation. With ADO.NET Data Services, you can do more than just query for instances across the wire. ADO.NET Data Services support the various HTTP verbs for Create, Read, Update, and Delete and provide the client-side abstractions to help developers implement their solutions. The second option for n-tier scenarios is the use of WCF with the Entity Framework, taking advantage of the ability to serialize entities and attach and detach entities from an ObjectContext. Figure 10 shows how to attach to an ObjectContext in this scenario. By default, any CLR classes that are generated from an EDM in Visual Studio or using edmgen.exe (the command-line tool that ships with the Entity Framework) are XML serializable, binary serializable, and are Data Contracts with the Navigation Properties attributed as DataMembers by default, making it possible to create ASMX Web services and use Entity instances in view state or WCF services. Like most ORMs, the Entity Framework currently does not support Data Manipulation Language (DML) operations for create, update, or delete. Changes must be applied to objects in memory, and building the entire graph to be persisted could require a number of round-trips to the database. One way that this can be avoided is through the use of the attach functionality offered by the ObjectContext. Using Attach allows you to instruct the infrastructure that the Entity already exists and that a set of operations should be performed in memory and then the changes pushed down. For additional information on ntier development with the Entity Framework, search the MSDN® Library, as more content will be added soon. Figure 10 Attaching to ObjectContext // the creation of the travel MyTravelPostEntities opens the connection // and sets up all the metadata information automatically for you. using (MyTravelPostEntities travelEntities = new MyTravelPostEntities()) { // attach the comment and delete. travelEntities.Attach(deleteComment); // call delete on the object travelEntities.DeleteObject(deleteComment); try { travelEntities.SaveChanges(); } catch (OptimisticConcurrencyException opt) { // catching this exception allows you to // refresh travelEntities with either store/client wins // project the travelEntities into this failed travelEntities. var failedEntities = from e3 in opt.StateEntries select new { e3.Entity }; travelEntities.Refresh(RefreshMode.ClientWins, failedEntities.ToList()); travelEntities.SaveChanges(); } } Just Another ORM? So far, the Entity Framework has been considered by many to be just another ORM in the marketplace, which is understandable when looking simply at the first version of the product. In that direction, much of what has been included in the product to this point enables a core set of scenarios that ORMs begin to tackle. Much of the analysis to this point, however, has pointed out that the Entity Framework does not in all cases cover what you might expect from some of the other ORMs in the marketplace, and this is a valid observation. The investment that Microsoft is making in this space is meant to extend well beyond that of a traditional ORM product, and the msdnmagazine.com Entity Framework, as I will discuss shortly is the first step in a much broader strategy around the EDM. The EDM, as I discussed at the beginning of this article, creates a higher level domain model that will be applicable beyond just Entity Framework and the world of traditional ORMs. The expectation is that over the next few releases of the Microsoft .NET Framework, Visual Studio, SQL Server®, and other Microsoft technologies, you will begin to see increased adoption of the EDM. This expectation and the overall vision of where the EDM is headed has been the primary influence for this, as seen in many of the product decisions discussed throughout this article. Many decisions have been made with the explicit intent of enabling adoption by technologies such as Reporting Services and Analysis Services. This will bring a strong benefit to customers as services are able to be offered across a common and consistent domain model. The first realization of this vision will ship alongside the Entity Framework in Visual Studio 2008 SP1 as ADO.NET Data Services. ADO.NET Data Services, which delivers a compelling developer experience for REST-based applications, will be the first released product (outside of the Entity Framework) to be built with the EDM as its metadata exchange format. In coordination with this release, Microsoft demonstrated a number of different Windows Live™ properties at MIX 2008, which expose their data using the ADO.NET Data Services protocol and the EDM. Similarly, as we begin now to plan for the next release of SQL Server and Visual Studio, the team is working hard on better end-to-end development experiences with EDM and Entity Framework at the core. Elisa Flasko is a Program Manager in the Data Programmability team at Microsoft, focusing on ADO.NET, XML, and SQL Server Connectivity technologies. She can be reached via her blog at blogs.msdn.com/elisaj. July 2008 75 http://blogs.msdn.com/elisaj http://msdnmagazine.com
Table of Contents Feed for the Digital Edition of MSDN Magazine - July 2008 MSDN Magazine - July 2008 Contents Toolbox CLR Inside Out Flex Your Data Data Points Advanced Basics Office Space Cutting Edge Data Services ADO.NET Data and WPF Transactions WCF P2P Test Run Security Briefs Foundations .NET Matters {End Bracket} MSDN Magazine - July 2008 MSDN Magazine - July 2008 - (Page Intro) MSDN Magazine - July 2008 - Contents (Page Cover1) MSDN Magazine - July 2008 - Contents (Page Cover2) MSDN Magazine - July 2008 - Contents (Page 1) MSDN Magazine - July 2008 - Contents (Page 2) MSDN Magazine - July 2008 - Contents (Page 3) MSDN Magazine - July 2008 - Contents (Page 4) MSDN Magazine - July 2008 - Contents (Page 5) MSDN Magazine - July 2008 - Contents (Page 6) MSDN Magazine - July 2008 - Contents (Page 7) MSDN Magazine - July 2008 - Contents (Page 8) MSDN Magazine - July 2008 - Contents (Page 9) MSDN Magazine - July 2008 - Contents (Page 10) MSDN Magazine - July 2008 - Toolbox (Page 11) MSDN Magazine - July 2008 - Toolbox (Page 12) MSDN Magazine - July 2008 - Toolbox (Page 13) MSDN Magazine - July 2008 - Toolbox (Page 14) MSDN Magazine - July 2008 - Toolbox (Page 15) MSDN Magazine - July 2008 - Toolbox (Page 16) MSDN Magazine - July 2008 - CLR Inside Out (Page 17) MSDN Magazine - July 2008 - CLR Inside Out (Page 18) MSDN Magazine - July 2008 - CLR Inside Out (Page 19) MSDN Magazine - July 2008 - CLR Inside Out (Page 20) MSDN Magazine - July 2008 - CLR Inside Out (Page 21) MSDN Magazine - July 2008 - CLR Inside Out (Page 22) MSDN Magazine - July 2008 - CLR Inside Out (Page 23) MSDN Magazine - July 2008 - CLR Inside Out (Page 24) MSDN Magazine - July 2008 - Data Points (Page 25) MSDN Magazine - July 2008 - Data Points (Page 26) MSDN Magazine - July 2008 - Data Points (Page 27) MSDN Magazine - July 2008 - Data Points (Page 28) MSDN Magazine - July 2008 - Data Points (Page 29) MSDN Magazine - July 2008 - Data Points (Page 30) MSDN Magazine - July 2008 - Data Points (Page 31) MSDN Magazine - July 2008 - Data Points (Page 32) MSDN Magazine - July 2008 - Data Points (Page 33) MSDN Magazine - July 2008 - Data Points (Page 34) MSDN Magazine - July 2008 - Advanced Basics (Page 35) MSDN Magazine - July 2008 - Advanced Basics (Page 36) MSDN Magazine - July 2008 - Advanced Basics (Page 37) MSDN Magazine - July 2008 - Advanced Basics (Page 38) MSDN Magazine - July 2008 - Advanced Basics (Page 39) MSDN Magazine - July 2008 - Advanced Basics (Page 40) MSDN Magazine - July 2008 - Advanced Basics (Page 41) MSDN Magazine - July 2008 - Advanced Basics (Page 42) MSDN Magazine - July 2008 - Office Space (Page 43) MSDN Magazine - July 2008 - Office Space (Page 44) MSDN Magazine - July 2008 - Office Space (Page 45) MSDN Magazine - July 2008 - Office Space (Page 46) MSDN Magazine - July 2008 - Office Space (Page 47) MSDN Magazine - July 2008 - Office Space (Page 48) MSDN Magazine - July 2008 - Office Space (Page 49) MSDN Magazine - July 2008 - Office Space (Page 50) MSDN Magazine - July 2008 - Cutting Edge (Page 51) MSDN Magazine - July 2008 - Cutting Edge (Page 52) MSDN Magazine - July 2008 - Cutting Edge (Page 53) MSDN Magazine - July 2008 - Cutting Edge (Page 54) MSDN Magazine - July 2008 - Cutting Edge (Page 55) MSDN Magazine - July 2008 - Cutting Edge (Page 56) MSDN Magazine - July 2008 - Cutting Edge (Page 57) MSDN Magazine - July 2008 - Data Services (Page 58) MSDN Magazine - July 2008 - Data Services (Page 59) MSDN Magazine - July 2008 - Data Services (Page 60) MSDN Magazine - July 2008 - Data Services (Page 61) MSDN Magazine - July 2008 - Data Services (Page 62) MSDN Magazine - July 2008 - Data Services (Page 63) MSDN Magazine - July 2008 - Data Services (Page 64) MSDN Magazine - July 2008 - Data Services (Page 65) MSDN Magazine - July 2008 - Data Services (Page 66) MSDN Magazine - July 2008 - Data Services (Page 67) MSDN Magazine - July 2008 - Data Services (Page 68) MSDN Magazine - July 2008 - Data Services (Page 69) MSDN Magazine - July 2008 - ADO.NET (Page 70) MSDN Magazine - July 2008 - ADO.NET (Page 71) MSDN Magazine - July 2008 - ADO.NET (Page 72) MSDN Magazine - July 2008 - ADO.NET (Page 73) MSDN Magazine - July 2008 - ADO.NET (Page 74) MSDN Magazine - July 2008 - ADO.NET (Page 75) MSDN Magazine - July 2008 - ADO.NET (Page 76) MSDN Magazine - July 2008 - ADO.NET (Page 77) MSDN Magazine - July 2008 - Data and WPF (Page 78) MSDN Magazine - July 2008 - Data and WPF (Page 79) MSDN Magazine - July 2008 - Data and WPF (Page 80) MSDN Magazine - July 2008 - Data and WPF (Page 81) MSDN Magazine - July 2008 - Data and WPF (Page 82) MSDN Magazine - July 2008 - Data and WPF (Page 83) MSDN Magazine - July 2008 - Data and WPF (Page 84) MSDN Magazine - July 2008 - Data and WPF (Page 85) MSDN Magazine - July 2008 - Data and WPF (Page 86) MSDN Magazine - July 2008 - Data and WPF (Page 87) MSDN Magazine - July 2008 - Data and WPF (Page 88) MSDN Magazine - July 2008 - Data and WPF (Page 89) MSDN Magazine - July 2008 - Data and WPF (Page 90) MSDN Magazine - July 2008 - Transactions (Page 91) MSDN Magazine - July 2008 - Transactions (Page 92) MSDN Magazine - July 2008 - Transactions (Page 93) MSDN Magazine - July 2008 - Transactions (Page 94) MSDN Magazine - July 2008 - Transactions (Page 95) MSDN Magazine - July 2008 - Transactions (Page 96) MSDN Magazine - July 2008 - Transactions (Page 97) MSDN Magazine - July 2008 - Transactions (Page 98) MSDN Magazine - July 2008 - Transactions (Page 99) MSDN Magazine - July 2008 - Transactions (Page 100) MSDN Magazine - July 2008 - Transactions (Page 101) MSDN Magazine - July 2008 - Transactions (Page 102) MSDN Magazine - July 2008 - Transactions (Page 103) MSDN Magazine - July 2008 - Transactions (Page 104) MSDN Magazine - July 2008 - WCF P2P (Page 105) MSDN Magazine - July 2008 - WCF P2P (Page 106) MSDN Magazine - July 2008 - WCF P2P (Page 107) MSDN Magazine - July 2008 - WCF P2P (Page 108) MSDN Magazine - July 2008 - WCF P2P (Page 109) MSDN Magazine - July 2008 - WCF P2P (Page 110) MSDN Magazine - July 2008 - Test Run (Page 111) MSDN Magazine - July 2008 - Test Run (Page 112) MSDN Magazine - July 2008 - Test Run (Page 113) MSDN Magazine - July 2008 - Test Run (Page 114) MSDN Magazine - July 2008 - Test Run (Page 115) MSDN Magazine - July 2008 - Test Run (Page 116) MSDN Magazine - July 2008 - Security Briefs (Page 117) MSDN Magazine - July 2008 - Security Briefs (Page 118) MSDN Magazine - July 2008 - Security Briefs (Page 119) MSDN Magazine - July 2008 - Security Briefs (Page 120) MSDN Magazine - July 2008 - Security Briefs (Page 121) MSDN Magazine - July 2008 - Security Briefs (Page 122) MSDN Magazine - July 2008 - Foundations (Page 123) MSDN Magazine - July 2008 - Foundations (Page 124) MSDN Magazine - July 2008 - Foundations (Page 125) MSDN Magazine - July 2008 - Foundations (Page 126) MSDN Magazine - July 2008 - Foundations (Page 127) MSDN Magazine - July 2008 - Foundations (Page 128) MSDN Magazine - July 2008 - Foundations (Page 129) MSDN Magazine - July 2008 - Foundations (Page 130) MSDN Magazine - July 2008 - .NET Matters (Page 131) MSDN Magazine - July 2008 - .NET Matters (Page 132) MSDN Magazine - July 2008 - .NET Matters (Page 133) MSDN Magazine - July 2008 - .NET Matters (Page 134) MSDN Magazine - July 2008 - .NET Matters (Page 135) MSDN Magazine - July 2008 - {End Bracket} (Page 136) MSDN Magazine - July 2008 - {End Bracket} (Page Cover3) MSDN Magazine - July 2008 - {End Bracket} (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.