Monday, November 24, 2008

LINQ and Entity Framework Posts for 11/17/2008+

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

Updated 11/24/2008 8:00 AM PST
• Updated 11/21/2008 9:00 AM PST
• Updated 11/20/2008 5:30 PM PST

Entity Framework and Entity Data Model (EF/EDM)

• Ayende Rahien reports substantial increases in NHibernate downloads and posts to the NHibernate users group in his The NHibernate Community post of 11/22/2008.

Rick Anderson’s How to create an updateable view with ADO Entity Framework and with LINQ to SQL post of 10/03/2008 describes what the title claims. (Thanks to Steve Naughton for the heads up on Rick’s MSDN blog, which I wasn’t watching but am now.)

•• Frans Bouma takes the EF Team to task for their plans to force developers to write their own client-side update tracking code, not to mention rolling their own “wire-level format for changes sent from client to another tier,” in his Baby-sitter Framework 2.0: Change tracking in the EF v2, it's still your problem post of 11/21/2008.

•• Ayende Rahien agrees with Frans in his Stealing from your client post of 11/21/2008. Ayende says “This Is Broken, By Design.” I agree with Ayende and Frans.

Jeff Derstadt, Jaroslaw Kowalski, and Diego Vega posted N-Tier Improvements for Entity Framework [v2] on 11/19/2008, which proposes the following “goal” for future n-tier implementations:

Entity Framework won’t define its own unique representation for the set of changes represented in an N-Tier application. Instead, it will provide basic building block APIs that will facilitate the use of a wide range of representations.

My Entity Framework Team Abandons Unified N-Tier Architecture for v2 provides more details about the team’s decision to abandon a unified n-tier architecture for EF v2.

Milind Lele mentions that VS 2010 will support drag-and-drop data binding for WPF in his Drag-drop data binding for WPF in Visual Studio 2010 (Milind Lele) post of 11/19/2008 and notes:

In VS2010 we've added support for EDM in the data sources window. Thus when you add an EDM to your project, the entities show up in the [D]ata [S]ources window. You can simply drag the entities and drop them onto your WPF form or control to bind them.

His earlier Drag-Drop Data Binding For WPF post of 11/8/2008 has a screen capture of Northwind EntitySets in the Data Sources window.

John Papa offers Code from DevConnections 2008 in Las Vegas (11/18/2008) for the following sessions:

  • Implementing the Entity Framework
  • Data Access with Silverlight 2
  • Developing with Enterprise Library Data Access Application Block

Kim Major’s Entity Framework – Some common hurdles post of 11/17/2008 describes how his repository implementation deals with the following issues:

  • No eager loading. Need to specify .Include(“”) for every query.
  • No way to make to turn change tracking on/off except from changing every query.
  • A bug that prevents simple queries where nvarchar columns are used in the criteria.
  • A designer error with a cryptic error message.

His earlier Data Access With The Entity Framework (11/12/2008) and Testable Data Access With The Repository Pattern (11/14/2008) posts describe Renaissance Computer Systems Ltd.’s EF-based framework.


••• Visual Studio Magazine’s “Speed O/R Mapping with LINQ to SQL” cover story by Roger Jennings for the December 2008 issue carries the following deck:

LINQ to SQL continues to be a top contender in the .NET object/relational mapping tool market despite Microsoft's promotion of the Entity Framework as one of the "Pillars of SQL Server 2008: Dynamic Development."

The article includes a table that compares LINQ to SQL and Entity Framework features and a “Visual Studio 2008 SP1 Add-Ins Remove LINQ to SQL Roadblocks” sidebar that describes Huageti Systems’ DBML/EDMX Tools utility for LINQ to SQL and Entity Framework and Damien Guard’s T4 template for customizing LINQ to SQL partial class code generation.

The LINQ to SQL Featured in Visual Studio Magazine’s December 2008 Cover Story post of 11/24/2008 adds related OakLeaf blog links and a couple of minor corrections to the text and table.

Rick Anderson’s How to create an updateable view with ADO Entity Framework and with LINQ to SQL post of 10/03/2008 describes what the title claims. (Copied from the “EF/EDM” topic.)

Kristofer Andersson’s Tools - Part 6 - Add-ins - “Model First” in Linq-to-SQL (and Entity Framework) post of 11/21/2008 describes a new feature of his Huagati DBML/EDMX Tools that enables generating the underlying database from a LINQ to SQL O/R Designer model and then incrementally updating the database schema with change scripts as the model matures.

Incremental updates are important because LINQ to SQL’s current model-first implementation [re]generates the entire database for each design update. The EF team’s stated intention for EF v2 is exactly the same. In both cases, the developer must recreate all data, relationships, indexes, etc. manually or author a hand-written change script. Regenerating the database for model changes is not acceptable in a production O/RM tool.

Kris’s post includes screen captures of an example that adds two tables related to Northwind’s Employees table. If you’re working with LINQ to SQL or EF, you need the Huagati DBML/EDMX Toolkit.

Deepak ? demonstrates how to Dynamic Sort With LINQ To SQL in this 11/19/2008 post. He writes a complex method with the Expression type, which he finally simplifies to a simple GetSortedEmployees<T> function with a lambda expression to specify the OrderBy predicate.

Matt Warren’s Building a LINQ IQueryable Provider - Part XII post of 11/17/2008, following a four-month hiatus, wraps the code from his previous 11 episodes into a single IQToolkit project that also includes testing code. Matt describes the changes from the earlier, incremental code base:

One of the first things you'll notice when you take a look at the source is that I changed it quite a bit.  I moved code around, changed names gratuitously, added & removed classes and broke a lot of continuity with the prior versions. One of the biggest changes is that the code is no longer just a sample.  All those internal classes are public, the project builds as a DLL, the tests are hosted separately and the namespace is no longer 'Sample.'

Bravo, Matt! A vituoso performance.

••• Matt posted his IQToolkit source code to CodePlex on 11/21/2008

Deepak ?’s  Enum Support With LINQ To SQL And SqlMetal post of 11/18/2008 describes his approach for using an enum in code. His “solution is to generate dbml file using SqlMetal, then run a custom process which modifies dbml to make it enum ready and finally generate code using SqlMetal looking over dbml file.”

LINQ to Objects, LINQ to XML, et al.

Bart De Smet’s Dude, Where’s My LINQ DML? post of 11/22/2008 discusses adding DML for “batch updates that don’t require client-side input or computation.” Bart demonstrates attempts at “Updateable LINQ to Objects,” “Updateable remotable LINQ,” and “Introducing IUpdateable<T>”, but bails with the following:

I’ll leave a concrete implementation of an update provider to the inspired reader; a basic prototype for SQL (only allowing columns to be updated with constant string or integer values) worked like a charm.

Bart: How about providing your “basic prototype for SQL” code?

Note: As reported last week, Rob Conery “added some spice to [SubSonic 3.0] and now we have a batch-updatable (read: one connection, one sql execution) Add/Update/Delete for the Repository which you can download here ([he]'ll include this in subsequent releases).”

Eric White demonstrates LINQ to XML generating an Inner Join of Two Excel Tables directly from the spreadsheet.Table(“TableName”) sources in this post of 11/20/2008.

LinqMaster’s Iterators, Lambda, and LINQ post of 11/20/2008 claims to be “The path to understanding Lambda and LINQ.” Sounds like LinqMaster is attempting to emulate Siddhartha Gautama in the LINQ department.

Aghy (Agnes Molnar) points to an updated version of LINQ4SP (LINQ to SharePoint) RC2 with its timebomb extended to 1/1/2009 in her Linq4SP - RC2 timebomb extended post of 11/20/2008. The earlier version expired a few days ago (in advance of the availability of paid licenses.)

Mike O’Brien’s Importing and Exporting Data Using Linq post of 11/18/2008 demonstrates how to export data from a SQL Server table to XML using LINQ to SQL and LINQ to XML.

ADO.NET Data Services (Astoria)

Marcelo Lopez Ruiz’s Limiting how many entities are returned from an ADO.NET Data Service post of 11/19/2008 explains that you can limit the number of entities on the server as well as with the $top query string option. Marcelo says:

MaxResultsPerCollection allows you to limit not only the number of entities returned at the top level of a request, but also at each collection within, so clients can't use '$expand' to overwhelm the server. Because a batch request can have multiple queries, you can combine that with MaxBatchCount.

However, use of these constraints is likely to throw exceptions.

He also cautions not to forget the dollar-sign prefix for system query parameters (options) in Filter not working in ADO.NET Data Services? of 11/18/2008

Brandon Bilinsky announced on 11/19/2008 that Like a Version; AtomPub Compliant for the Very First Time v2 of the Google Data APIs is fully compliant with the AtomPub standard (RFC 5032.) Like Astoria, Data APIs v2 uses HTTP ETags for optimistic concurrency management. Google’s Java and .NET client libraries have been updated with v2 support.

Rick Strahl’s ASP.NET Connection Session Slides and Samples Posted of 11/17/2008 describes and provides links to these sessions:

  • Using WCF for REST and JSON Services with ASP.NET
  • Using jQuery with ASP.NET
  • Dealing with Long Running Requests in ASP.NET

ASP.NET Dynamic Data (DD)

Rick Anderson solves a problem that occurs when you scaffold AdventureWorks’ CustomerAddress column in his Improving the FK field display: Showing two fields in Foreign Key columns with EF post of 11/21/2008. By default, DD turns the table’s first string column into a lookup field, in this case the Title field. Rick corrects the problem “by creating and annotating a partial class for the  Customer entity.”

Jonathan Carter’s Dynamic Data: The Little MetaModel That Could post of 11/20/2008 delve deeper into DD’s metadata classes: MetaTable and MetaColumn.

• Jonathan Carter posts the third episode as Dynamic Data: Models, MetaModels And Everything In Between on 11/19/2008. He notes that Dynamic Data provides …

A common meta-model system for describing data models with a higher semantic that a UI can leverage to be smarter by default. Out of the box, it includes providers for LINQ-To-SQL and the Entity Framework (which is why it has gotten a reputation for working solely against databases), but nothing stops it from working against any other data source. In fact, prototypes already exist that have Dynamic Data working against an ADO.NET Data Service, as well as a SQL Data Service.

Jonathan Carter follows up the first DD episode with Dynamic Data: Kickin’ It Old School of 11/19/2008, which provides a “contextual explanation as to why you might want to [leverage Dynamic Data within an existing web application], and what benefits may exist.

Jonathan Carter’s Dynamic Data: Come For The Scaffolding, Stay For Everything Else post of 11/17/2008 is the first episode of a new series about ADO.NET Dynamic Data. You might recall Jonathan’s earlier multipart series about ADO.NET Data Services.

Azure, SQL Data Services (SDS) and Cloud Computing

Roger Jennings uploaded the OakLeaf Systems Azure Table Services Test Harness to Windows Azure on 11/23/2008 and it’s now live at For more details, see Windows Azure Test Harness Is Live! of the same date. A few features are disabled in the publicly available version.

Mike Amundson observes that SDS currently supports JSON (and ATOM) wire formats with Astoria functionality in his reply of 11/20/2008 to the JSON as alternative to XML for REST requests? thread in the SQL Data Services (SDS) - Getting Started forum.

The SDS Team’s Evan Basilik commented on the same date that “It does work, but is not an entirely "baked" part of the product.” Later posts request reassurance that, unlike Astoria, SDS will continue to support Plain Old XML (POX).

James Urquhart’s Do Your Cloud Applications Need To Be Elastic? post of 11/21/2008 quotes Citrix’s Cris Flex’s Cloud Economics 101 - Part 1 post of 9/27/2008 compares the cost of on-premises versus cloud computing on Amazon’s EC2. James concludes that cloud computing (with EC2) is only competitive with on-premises operations if you take full advantages of the ability to add and remove instances to satisfy periodic load peaks.

(Chris’s Cloud Economics 101 Part 2 - Premise Plus Cloud post of 10/13/2008 analyzes supplementing on-premises hosting with cloud computing for short-term demand spikes.)

Roger Jennings added the last three episodes to his Azure Storage Services Test Harness series:

  • Table Services 7 – Testing for Table Existence at App Startup Only (11/22/2008)
  • Table Services 6 – Paging LINQ to REST Query Result Sets (11/22/2008)
  • Table Services 5 – Generating Classes/Collection Initializers with LIMOG v2 (11/21/2008)

    • Pat Helland’s An Interview with .NET Rocks while I Was at Barcelona Last Week post of 11/20/2009 contains a link to an interview about the five sessions Pat presented at Tech*Ed EMEA 2008 Developer:

    1. When You Have Too Much Data, “Good Enough” is Good Enough
    2. Building on Quicksand
    3. RIAs and Emissaries
    4. Metropolis: Buildings and Applications
    5. Title Missing

    All have some relationship to cloud computing, but the interview emphasized topic #1.

    Roger Jennings added two new episodes to his Azure Storage Services Test Harness series:

    The goal is to wrap up the series by the end of this week.

    David Aiken’s illustrated Peeking [into] Windows Azure Queues using Windows PowerShell post of 9/12/2008 shows you how to use the CloudDrive Windows PowerShell provider from the Azure sample projects to browse and read queues.

    John Foley notes in his Next Headache: Cloud Chaos post of 11/19/2008 that:

    InformationWeek is preparing a report on how to get into cloud services, a hands-on guide to help you make a smooth transition, which we will publish in December. Those who want to ride the learning curve with peers should consider attending Cloud Connect, an "unconference" with a learn/develop/demo format. The event, co-sponsored by InformationWeek, takes place Jan. 20 to 22 at the Computer History Museum in Mountain View, Calif.

    So far, the “unconference” agenda has a severe case of the “Berkeley Vagues.”

    Steve Marx eliminates the performance hit caused by executing the CreateTablesFromModel() method against Azure Table Services on each server round trip in his Try to Create Tables Only Once post of 11/18/2008. I put his approach to work in the Global.asax.cs file added to my Azure Storage Services Test Harness.

    Oren Melzer’s The CardSpace “Geneva” Selection Experience post of 11/17/2008 explains the “newly designed selector in the new CardSpace ‘Geneva’ beta.” CardSpace is one of the authentication methods for the Azure Services Platform.

    Microsoft announced its Microsoft Business Productivity Online Standard Suite (MBPOSS) on 11/17/2008 and Mary Jo Foley analyzed its SharePoint capabilities in her What does ‘SharePoint in the cloud’ really mean? post of the same date. MBPOSS offers Exchange Online, SharePoint Online, Office Live Meeting, and Office Communications Online (later) “in the cloud” to potential users starting at $15.00 per month.

    Werner Vogels describes Amazon Web Services’ new edge-based content distribution network (CDN) for S3 called CloudFront in his Expanding the Cloud: Amazon CloudFront post of 11/17/2008. Nice name, by the way.

    SQL Server Compact (SSCE) 3.5 and Sync Services

    Steve Lasker’s Tech Ed EMEA 08 Powerpoints and Demos post of 11/19/2008 has links to slides and demo code from his two presentations:

    • DAT314  Unlocking the Power of SQL Server Compact 3.5
    • DAT405 Managing and Versioning Client Databases 

    Miscellaneous (WPF, WCF, MVC, Silverlight, etc.)

    Sam Gentile posted the 11th member of his SOA: Making the Paradigm Shift Part series on 11/23/2008 as Introduction to WCF: Architecture and the "ABCs" of Indigo." Sam says “The focus of this post is to show "Hello Indigo" code in a step-by-step manner. We will dive deep into the Indigo Architecture in the next installment of this series.”

    Rick Strahl attempts to divine the appropriate data transfer model to SQL Server parameterized stored procedures in his Silverlight and Data Communications post of 11/20/2008.

    David Betz’s Understanding WCF Services in Silverlight 2 of 11/16/2008 is a full-length tutorial for “access[ing] WCF services using Silverlight 2 without magic. There will be no proxies, no generated code, and no 3rd party utilities. Just raw WCF.”

    Rico Mariani’s The Visual Studio Tech Roadmap -- Starring Visual Studio 2010 post of 11/18/2008 presents Visual Studio’s chief architect’s view of the goals for VS 2010 and later, including a reference to future cloud-computing capabilities and tools (see the Danny Thorpe item below.)

    Simon Segal explains how he’s Moving on from Windows & Web Forms to Silverlight 2.0 in this detailed post of 11/18/2008.

    Scott Guthrie notes that Silverlight 3 will have “richer data-binding support” in his Update on Silverlight 2 - and a glimpse of Silverlight 3 post of 11/16/2008.

    Dare Obasanjo’s Live Framework (LiveFX), Is it Microsoft's GData or Something More? post of examines LiveFX and concludes:

    The client-side Live Operating Environment is a technology whose benefits elude me. I admit it is kind of cool but I can't see its utility.

    Danny Thorpe responds in his Client-Side Live Operating Environment: What’s It For? post of 11/18/2008 that “The answer, in a word, is ‘offline.’” Danny was a Principal Software Development Engineer for LiveFX who left Microsoft in October 2007 and returned in May 2008. He joined the Visual Studio incubation team that’s “working on stuff to make accessing Windows Live services easier for developers,” and is now Principal Engineer, Cloud Computing Tools.

    Kristofer Andersson’s Data Model - Basics - Part 11 - The HuagatiRes data model converted to “M” post of 11/15/2008 describes his conversion of the HuagatiRes airline passenger reservation system data model into an Oslo M script with a “code snippet that extracts schema, type, table, column, foreign key, and index defs and generates M files.” Kris says:

    Give it a connect string and an output folder and it will generate one M file per schema in the database you point it at, complete with code comments (based on object names and extended property descriptions) and all. Even [commented out] index definitions - prepared for the day when M gets support for index definitions.

    P.S.: Aker Brygge is the site of a former Norwegian shipyard (near Oslo) that’s been converted into a “shopping center with shops and restaurants, a cinema, office space, and apartments. Additionally, there is a small boat harbour, and a terminal for the ferries to Nesodden (across the Oslo fjord).”

    Kathleen Richards quotes me in her A Tale of Two 'Cities' article about Oslo and Dublin for Redmond Developer News’ November edition:

    Data-driven app developer Roger Jennings, a contributing editor to Redmond Developer News' sister publication Visual Studio Magazine and OakLeaf Systems blogger, says with Oslo Microsoft is moving toward a repository for componentized software. The company's intention is to make the visual designer Quadrant usable by business analysts -- to modify workflows, for example -- but whether that will work is unclear.

    "My feeling about Oslo is that they're trying to get business analysts involved in the design process, but not necessarily doing the design," says Jennings.