Tuesday, June 24, 2008

LINQ and Entity Framework Posts for 6/23/2008+

Note: This post is updated daily or more frequently, depending on the availability of new articles.

Initial Entity Framework POCO DesignFeature 1-Pager  on Entity Framework Design Blog

True to his word, Tim Mallalieu posted on June 24, 2008, an Initial POCO Design 1-Pager which was intended to be an “Initial POCO Feater 1-Pager.”

The post starts with a Part 1 Overview that lists Jimmie Nilsson’s six requirements/assumptions that are verboten in a persistence ignorant design.

Part 2 Context reiterates that POCO support in v2 would require abandoning the IEntityWithRelationships and IEntityWithChangeTracking interfaces and POCOs can’t use attributes to map object members to the conceptual schema.

Part 3 Design shows classes for Customer and Order entities with a 1:many relationship between them.

O-Space to C-Space mapping is done by convention – i.e. the CLR types of the entities below map to the corresponding entities already defined in the Conceptual Model.

Code for the POCO partial classes for such entities is shown, together with a sample query and addition of a pair of entities. So far, it looks like POCO to me.

Added: 6/24/2008

Tim Mallalieu Addresses “ADO .NET Entity Framework Vote of No Confidence” Manifesto

In the tradition of Émile Zola’s “J'accuse” and Martin Luther’s The 95 Theses letters, the ADO .NET Entity Framework Vote of No Confidence petition in the form of a WuFoo form with attached Entity Framework Vote of No Confidence Signatories table had gathered more than 150 signatures by mid-afternoon on June 24, 2008.

It’s certain that Mary Jo Foley’s Testers give Microsoft’s Entity Framework a no-confidence vote post of the same date was responsible for the rapid increase in signatories during the afternoon.

Read all about the manifesto and Tim’s Vote of No Confidence reply in this full-length post.

Update 6/25/2008: Mary Jo’s column hit Techmeme on 6/24/2008 at 4:45 PM. My favorite comment to her column: “I'm not a tester: I've never installed nor tested an Entity Framework beta, but I signed the vote of no confidence” by odenni.

The manifesto had 226 signatories by 6/25/2008 at 8:30 AM.

Added: 6/24/2008 1500 PDT

New Entity Framework Design Blog Announces Transparent v2 Design Process

Tim Mallalieu’s first post since taking over as Entity Framework (EF) program manager in the Autumn of 2007, Transparency in the design process of June 23, 2008, describes what’s in store for EF v2:

  • Persistence Ignorance (PI) and Plain Old CLR Objects (POCO
  • N-Tier Support for remoting object graphs with change tracking using WCF
  • Code-First domain modeling instead of v1’s data-centric, forms-over-data approach
  • Test-Driven Development (TDD) Scenarios with POCO
  • Foreign Key modeling support in addition to associations
  • Lazy Loading options, possibly implicit lazy loading
  • Query Tree Re-Writing to filter query results horizontally and vertically

Tim is adopting Pablo Castro’s transparent design process for ADO.NET Data Services (Astoria), which I recommended to the SQL Server Data Services (SSDS) team last week.

For the full story see the New Entity Framework Design Blog Announces Transparent v2 Design Process post of 6/24/2008.

Added: 6/24/2008 and moved to a separate post.

Scott Hunter Explains How to Integrate Dynamic Data Pages with an Existing ASP.NET Web Application

Scott’s earlier post, reported in the “Scott Hunter Demonstrates Integrating Dynamic Data with an Existing ASP.NET Site” topic below covers integrating ASP.NET Dynamic Data with file-system Web sites.

His How to add Dynamic Data to an Existing Web Application sequel of June 24, 2008 covers conventional ASP.NET Web applications.

The process is a bit different for Web apps because you use Project Explorer’s Add Reference feature to add the System.ComponentModel.DataAnnotations, System.Web.Abstractions, and System.Web.DynamicData and System.Web.Routing namespaces.

Scott notes that you also must conform namespaces in the Dynamic Data code-behind files you add.

Added: 6/24/2008

Jaroslaw Kowalski Posts a “Not for Production” Entity Framework Provider for Oracle

Jarek’s Sample Entity Framework Provider for Oracle post of June 23, 2008 describes an entity provider similar to the EFSampleProvider but targets System.Data.OracleClient instead of System.Data.SqlClient.

Some interesting non-default type mappings:

  • EFOracle.number(1,0) maps to Edm.Boolean
  • EFOracle.number(5,0) maps to Edm.Int16
  • EFOracle.number(11,0) maps to Edm.Int32
  • EFOracle.raw(16) maps to Edm.Guid

Jarek says the following about Canonical Functions:

Most Canonical Functions required by Entity Framework have been implemented using Oracle's built-in functions. In some cases it required some query rewriting, such as when handling Right() canonical function which has no direct Oracle translation and SUBSTR() must be used instead.

Danny Simmons’ Items of Interest: Sample Oracle Provider, Transparent Design Process post of June 24, 2008 points out:

I should stress that this is a sample not an official supported Oracle provider from Microsoft, but it is designed to help provider writers learn more about building providers for the EF, as well as to highlight some of the particular challenges encountered in briding between the EF's view of the world and that of Oracle, to fully demonstrate the provider-agnostic nature of the EF, etc.

Added: 6/24/2008 1000 PDT

Justin Etheredge Starts Two-Part Series about LINQ Expression Trees

Justin’s Dissecting Linq Expression Trees - Part 1 post of June 23, 2008 explains why LINQ expression trees are called Abstract Syntax Trees (ASTs) and explains why they are handy for:

  1. Tree modification before execution - You can actually modify the tree before it is compiled. You could join operations or simplify the tree before compiling it.
  2. Combining trees: This is in line with number 1, but you can take multiple expression trees and combine them using new Expression tree nodes. (Yes, you can manually generate these, and we will get into those later on)
  3. Alternate Execution: You can take an expression tree and interpret it and execute it in your own manner. This is precisely what LINQ To SQL does. It takes an expression tree and interprets it, then turns it into SQL instead of runnable MSIL

This post covers items 1 and 2. Part 2 will cover item 3.

 Added: 6/24/2008 1015 PDT

Mike Pizzo to Push Entity Framework and ADO.NET Data Services Tuesday at Sys-Con’s SOA World Conference & Expo in the Big Apple

The SOA World Magazine News Desk ran this somewhat redundant LINQ, Entity Framework and ADO.NET Entity Framework and Data Services for the Web head for a story about a presentation by the ADO.NET Data Programmability Group’s Principal Architect, Mike Pizzo, to the 13th International SOA World Conference & Expo 2008 East at the Hotel Roosevelt in New York City.

Strangely, Mike’s presentation is missing from the “Speakers/Sessions from Industry-Leading Companies” list on the SOA conference’s main page. It turns out that he’s speaking at Data Services World at SOA World 2008. Another case of you can’t tell the conferences from one another without a program.

Added: 6/23/2008 1710 PDT

Update 6/24/2008: I assume that Mike is announcing the the Entity Framework v2 transparent design program a the conference.

Mike Kaufman Tackles Model and Code Generation in Episode 2 of the Entity Framework Tools Series

Mike’s EDM Tools | Options (Part 2 of 4) post of June 23, 2008 describes how to use EdmGen.exe to generate the CSDL file with the EntityStoreSchemaGenerator object and the MSL/SSDL files with the EntityModelSchemaGenerator, as well as EntityClassGenerator to generate the partial entity classes. The post includes a link to download the related source code.

The next and final episode will take on validation and view generation.

Scott Hunter Demonstrates Integrating Dynamic Data with an Existing ASP.NET Site

Few sites that use ASP.NET Dynamic Data will consist solely of scaffolded pages. Scott’s How to add Dynamic Data to an Existing Web Site post of June 23, 2008 provides detailed, step-by-step instructions for integrating scaffolded pages into an existing ASP.NET site. The process involves:

  1. Creating a dummy ASP.NET Dynamic Data Web site and copying the DynamicData folder as well as Site.css and Site.master files to the existing project.
  2. Copying the Global.asax file to the existing site or add the model registration and routes to an existing Global.asax file.
  3. Modifying Web.config’s <compilation>, <pages>/<controls>, <httpModules> or <system.webServer>/<modules> sections.
  4. Registering your data model (LINQ to SQL, Entity Framework, LLBLGen Pro, etc.) and, optionally, enabling scaffolding.

Scott notes:

We hope to add a tooling gesture to Visual Studio in the future to automatically do these steps. Once these steps are complete you can start taking advantage of Dynamic Data functionality in your existing applications.

A Wizard dialog to handle the preceding steps sounds like a good idea to me.

Bart De Smet Continues His LINQ to MSI Implementation by Adding “Fluent Classes”

In his LINQ to MSI - Part 2 - Queryable without an I post of June 23, 2008, Bart introduces “a series of ‘fluent classes’ that provide a limited query pattern.” Topics of the lengthy article are:

  • The query provider
  • Representing tables
  • The built-in query pattern
  • Query data
  • Back to the Table<T>
  • Query, OrderedQuery and ClosedQuery
  • Known limitations

Bart’s next post will cover query translation.

Jim Wooley Explains How to Emulate Dynamic SQL with a Stored Procedure for Retrieving Associated EntitySets and EntityRefs

Jim’s Fetching child records using Stored Procedures with LINQ to SQL Post of June 23, 2008 shows how to write methods of the DataContext’s partial implementation to return EntitySets or EntityRefs from associated entities.

He also reminds those who’ve forgotten: LINQ is not about working with databases

John Papa Provides a Handy Cheat-Sheet for Silverlight 2 Data Binding Modes

His Sivlerlight 2 Binding Modes Diagram from his forthcoming Data Access with Silverlight 2 book illustrates how OneTime, OneWay, and TwoWay data bindings behave.