Friday, September 12, 2008

LINQ and Entity Framework Posts for 9/8/2008+

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

•••• Updated 9/14/2008 7:00 AM PDT: Addition of EF POCO v 1.02
••• Updated 9/12/2008 9:00 AM PDT: Additions to EF, LINQ, Astoria, SSDS, and Sync Services  
•• Updated 9/11/2008 2:00 PM PDT: Additions to EF, LINQ to SQL, LINQ (to NHibernate and XML), Misc. (Technorati, MVC) 
• Updated 9/10/2008 10:00 AM PDT: Additions to LINQ to SQL, Astoria, Dynamic Data, and SQL Server Compact

Note: All DevDays 2008 session links point to the MSDN Spotlight page because login with a Windows Live ID is required and links without a session ID fail.

Entity Framework and Entity Data Model (EF/EDM)

•••• Jarek Kowalski has updated his Persistence Ignorance (POCO) Adapter for Entity Framework V1 (see below) to v1.02 to fix three issues reported by users that his EF POCO Adapter updated (v1.02) post of 9/13/2008 describes. Download the updated code here.

••• Elisa Flasko’s PDC 2008 - Los Angeles, CA - Oct. 27-30 post of 9/12/2008 to the ADO.NET Team blog describes Tim Mallalieu’s Entity Framework Futures session at PDC 2008:

The next version of the Entity Framework adds scenarios in the areas of   model driven development, domain driven development, simplicity, and integration. See a preview of production and prototype code for the next version of the Entity Framework as well as a candid discussion with members of the development team.

In the meantime, EF V1 pilgrims are still awaiting the arrival of the promised minutes of the first EF Advisory Council meeting.

Alex James provides a detailed description of the plans for adding a domain-design-first feature to Entity Framework v2 in his Model First post of 9/10/2008. Topics include:

  • Generating Databases from Models (an overview of the process and UI)
  • Under the Hood (a description of the Sequential Workflow WF implementation)
  • Stage and Purpose (of each WF element)
  • Templates (the T4 templates that perform CSDL to SSDL, CSDL to MSL, and SSDL to DBSchema transformations)

Huageti Systems’ Kristofer Andersson notes in his Tools - Part 5 - Add-ins - Documentation features in Entity Framework vs Linq-to-SQL post of 9/2/2008:

[EF’s documentation feature] has a cosmetic flaw: In the haste to release VS2008 and .net 3.5 SP1 it seems like MSFT forgot to apply the entity type documentation to the entity set accessor properties, so entity sets (and all undocumented classes and properties) will show the default “There are no comments for [name] in the schema.“. I would like to see the EntitySet using the same documentation as the EntityType, or at least have a “Documentation” property of its own. (It does in the EDMX, but not in the designer)

The “There are no comments” default value is a bit redundant and waste of screen real-estate. Why not leave the default value blank? Oh well, this is just version one so I guess that will be improved in some future service pack update.

Also missing is the ability to automatically populate the documentation field with descriptions from data model diagrams and/or the database. The descriptions may already exist in a data model diagram or in the database. In addition, knowing what indexes exist is very useful when writing queries, and what indexes exist on tables etc are of course available from the database so being able to automatically retrieve those two pieces of information from the db would be a nice-to-have feature.

According to Alex, EF v2 will include metadata for indexes because the generated DDL add them.

Note that Damien Guard has produced an initial set of T4 templates for serializing LINQ to SQL classes, as described in my Bidirectional Serialization of LINQ to SQL Object Graphs with Damien Guard’s T4 Template in VS 2008 SP1 of 7/27/2004. A later version will add:

  • Inheritance support
  • VB.NET generation
  • DataContract serialization

But it won’t support stored procedures or composite primary keys.

Jarek Kowalski’s Persistence Ignorance (POCO) Adapter for Entity Framework V1 post of 9/9/2008 provides extensive details about the new EFPocoAdapter that’s available for download from the CodeGallery. Here’s its description:

EF POCO Adapter enables Plain Old CLR Objects (POCOs) to be tracked using released version of Entity Framework V1. It consist of a code generator, supporting library and a test suite and examples.

Code generator writes an adapter layer that will translate between POCO objects and Entity Framework-aware objects and provide services on top of POCO objects, such as:

  • Change tracking (snapshot-based and proxy-based when possible)
  • Transparent lazy loading
  • Immutable Value Objects
  • Queries (LINQ and Entity SQL)
  • Shadow state (maintaining certain persistence-related fields outside of entity class)

Entity Framework V1 programming interfaces are wrapped with corresponding APIs that work with POCO objects and do necessary translation between POCO and Persistence-Aware objects.

The availability of the new adapter should quiet the tumult and shouting about EF’s lack of persistence ignorance.

• Update 9/10/2008: From comments to Jarek’s post:

Roger Jennings (9/9/2008):

Does Astoria consider the POCO Adapter's EFPocoContext a first-class data source, that is, supports IQueryable<T> and induces the Astoria runtime to provide IUpdatable<T>?

In other words, can it be plugged into an Astoria project without adding a significant amount of code?

Jarek Kowalski (9/9/2008):

I'll investigate the Astoria question, but since EFPocoAdapter does not implement IUpdatable I don't think it works now. …

OK. I have played with Astoria and I was able to get a basic service to work. All you have to do is to derive from DataService<adapterContextType>, such as:

public class NorthwindEFService : DataService<NorthwindEntitiesAdapter>
{
}

This makes use of the "second face" of the object model, which is the EF-compatible adapter layer. Astoria doesn't have a clue that it is talking to POCO model, but the EF-POCO translation happens under the hood.

Implementation of IUpdatable should be pretty straightforward, though.

Mike Taulty presents Understanding the ADO.NET Entity Framework at DevDays 2008 Amsterdam (Video, May 2008).

LINQ to SQL

•• Mike Tulty’s Messing with Dynamic LINQ Queries post of 9/11/2008 shows his attempt with a LINQ to SQL query:

[T]o take the Expression which will have 2 parameters and reduce it down to an Expression which has 1 parameter by hard-wiring the 2nd parameter with the current value of the loop variable "s" into the method call expression itself as a constant.”

• Mike Hadlow has posted a working sample and source code for the Suteki Shop eCommerce application that uses the following technologies:

  • .NET 3.5
  • MVC Framework
  • LINQ to SQL
  • Windsor IoC Container
  • NUnit (for testing)
  • Moq (for mocking)

• Matt Manela explains in his SQL CE 3.5 with LINQ to SQL post of 9/9/2008 how to avoid the performance hit caused by moving SQL Server Compact (SSCE) 3.5 into and out of memory when LINQ to SQL opens and closes connections on single or multiple threads.

Bill BurrowsASP .NET MVC Framework - Preview 4 Update demonstration “highlights the changes in the MVC model since the release of Preview 1 and covers both "drill-down" applications as well as showing how to update and existing database record and add a new record” with VS 2008 (not SP1), LINQ to SQL and VB.

It’s unfortunate that the demo is one service pack and preview behind, but most of the two video links apply to current releases.

Bill also offers a VB-based LINQ to SQL Tutorial and Introduction to MVC Tutorial.

Anko Duizer presents Is LINQ to SQL your data Access Layer? from DevDays 2008 Amsterdam (Video, May 2008).

LINQ to Objects, LINQ to XML, et al.

••• Eric White describes how LINQ used C# 3.0’s closures feature in his Closures post of 9/12/2008.

•• Ayende Rahien‘s NHibernate 2.0 and Linq post of 9/11/2008 delivers formal notification that LINQ to NHibernate is not part of the recently-released NHibernate 2.0, but an improved LINQ implementation will be part of NHibernate 2.1.

However, he notes that “Daniel Guenter has back ported the current version of Linq to NHibernate to Nhibernate 2.0 and made it available here.”

Mike Hadlow noted problems with LINQ to NHibernate and complex queries in his What's up with Linq to NHibernate? post of 9/2/2008.

•• Shayne Burgess notes that the XML Team plans to incrementally publish “frequently encountered issues in System.XML; mainly points that we felt were interesting because they were the source of a lot of difficulty for our users.” The first two members of the Frequently Asked Questions on XML in .NET series are:

  1. Part 1: Invalid Literals (9/10/2008)
  2. Part 2: Conformance Level – Fragment (9/10/2008)

While not specifically about LINQ to XML issues, they should be of interest to developers using LINQ to XML.

John Papa describes a workaround for an Amazon Web Services’ book price ambiguity in his LINQ to XML Tip - Checking for Values post of 9/9/2008.

Eric White explains “how to use content controls in Open XML word documents to delineate code snippets so that you can automate validation of the snippets” in his OpenXmlCodeTester: Validating Code in Open XML Documents post of 9/8/2008. Eric says:

I suspect that this blog post will be very interesting to a very few people, but of casual note to all others. I’m very interested to hear if this scenario is useful to you. But more than this particular scenario, I want to spark interest in the possibilities that content controls open up for you.

This may be the longest blog post I’ve written, because this blog post also serves as a manual of sorts for OpenXmlCodeTester.

Eric’s code is based on functional programming principles and all variable values are immutable.

Sessions from DevDays 2008 Amsterdam (Video, May 2008):

ADO.NET Data Services (Astoria)

••• Elisa Flasko’s PDC 2008 - Los Angeles, CA - Oct. 27-30 post of 9/12/2008 to the ADO.NET Team blog describes the following two Astoria presentations at PDC 2008:

Developing Applications Using Data Services: Mike Flasko

In the near future, applications will be developed using a combination of custom application code and online building block services, including data-centric services. In this session we discuss advancements in the Microsoft development platform and online service interfaces to enable seamless interaction with data services both on-premises (e.g., ADO.NET Data Services Framework over on-premises SQL Server) and in the cloud (e.g., SQL Server Data Services). Learn how you can leverage existing know-how related to LINQ (Language Integrated Query), data access APIs, data-binding, and more when building applications using online data.

Offline-Enabled Data Services and Desktop Applications: Pablo Castro

The ADO.NET Data Services Framework (a.k.a. Project "Astoria") introduced a way of creating and consuming flexible, data-centric REST services. By combining data services with the Microsoft Sync Framework, learn how to create offline-capable applications that have a local replica of their data, how to synchronize that replica with an online data service when a network connection becomes available, and how replicas can be used with the ADO.NET Entity Framework. Also, hear us talk about our plans, see the tools that help client- and server-side setup, and discuss the runtime components and APIs.

Mike Flasko’s ADO.NET Data Services Concepts post of 9/9/2008 points to a new "Overview of ADO.NET Data Services" white paper on MSDN. Mike says:

The document is meant to cover the high-level concepts for the product.  A companion paper "Using ADO.NET Data Services" published a little while ago complements this overview with details on product features and how to use them. 

Coming up next is a paper which goes one level deeper and shows how to host data services in different environments (ASP.NET, WCF, IIS, WCF self host, etc).

Click here for more information from LINQ and Entity Framework Posts for 9/2/2008+ about the companion paper.

Sessions from DevDays 2008 Amsterdam (Video, May 2008):

ASP.NET Dynamic Data (DD)

•• Mike Ormond’s Dynamic Data and Entity Framework post of 9/11/2008 describes exceptions thrown when using EF with Northwind as the data source: one with the Order_Details entity and one when navigating the Product –> Order_Details relations (that composite index issue again!) The fix is the Dynamic Data Entity Framework Workaround on CodePlex.

Steve Naughton completes his Dynamic Data Futures series with his Dynamic Data Futures – Part 3 – AnyColumnAutocomplete Filter post of 9/9/2008. Steve says:

The issue is that the Autocomplete filter and AutocompleteFilter web service is designed to work with Foreign Key columns, I thought this would be like the previous article in this series and be quite simple, instead it turned out to be a bit more complicated

SQL Server Data Services (SSDS)

••• Eugenio Pace lauds Apprenda’s SaaSGrid cloud services framework for ISVs in his Northwind Hosting exists, it's better than what you saw and it's called SaaSGrid post of 9/12/2008. Eugenio says:

This "non-intrusiveness" of SaaSGrid is a property of PaaS offerings we have studied in the past. I personally believe that all offerings requiring an ISV to re-write an app, or re-learn a whole new development paradigm (custom language, non-mainstream storage, etc) will be at a disadvantage compared to PaaS offerings that will make the most of your existing investments and strengths, and therefore adoption will be hurt (probability +80% :-)).

Eugenio’s Northwind Hosting concept demo and related white papers form much of the foundation of SSDS and especially the LitwareHR demo. Watch the video to learn more about SSDS’s current and future architecture and features.

Mike Amundsen updated his “SSDS-Proxy and SSDS Provision Client code on 9/8/2008 to support returning the Authority List for the logged-in user. This update also includes support for reading and deleting BLOB files (no upload via the web - yet).”

A live demonstration is running here http://amundsen.com/ssds/. The source code is available from Codeplex http://codeplex.com/ssdsexamples/.

SQL Server Compact (SSCE) 3.5 and Sync Services

••• See Offline-Enabled Data Services and Desktop Applications: Pablo Castro

• Matt Manela explains in his SQL CE 3.5 with LINQ to SQL post of 9/9/2008 how to avoid the performance hit caused by moving SQL Server Compact (SSCE) 3.5 into and out of memory when LINQ to SQL opens and closes connections on single or multiple threads. (Also in LINQ to SQL category.)

Martijn Beenes presents Sync Framework from DevDays 2008 Amsterdam (Video, May 2008).

Visual Studio 2008 Service Pack 1 (General)

Beth Massi’s What's New in Visual Studio 2008 SP1 - Client and Data Features post of 9/11/2008 includes links to the slides and code from her presentation to the East Bay.NET UG on some of the new features in Visual Studio Service Pack 1, including:

  • SQL 2008 Types and Data Binding Support
  • ADO.NET Sync Services Enhancements
  • WPF Enhancements
  • ADO.NET Entity Framework Designer
  • ADO.NET Data Services (Astoria)
  • “Client Profile” Framework Deployment
  • VSTO Content Controls and Smart Tags
  • VSTO Deployment Improvements

I wonder how long the meeting lasted.

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

•• (OT) Roger Jennings takes Technorati to task for making acquisitions while failing to maintain their primary obligation to the blogosphere and provide timely customer service in his More Technorati Troubles post of 9/11/2008.

These two posts re Technorati were added on 9/12/2008:

Update 9/11/2008 2:30 PM PDT. Apparently the above post caught Technorati’s attention. The latest posts are now appearing and the Authority was updated (-2 points.)

David Hayden’s ASP.NET MVC and Enterprise Library Validation Application Block post of 9/10/2008 complements his earlier post with instructions for integrating the Validation Application Block with ASP.NET MVC.

Scott Heuer says in his 9/9/2008 post, H.264 and AAC support coming to Silverlight (in a future version). The Silverlight Shines at International Broadcasting Conference 2008 in Amsterdam press release of the same date includes Q&A with Scott Guthrie about the new video codecs for Silverlight.

Mike Taulty’s Silverlight, Async, Events post of 9/8/2008 deals with issues around asynchronous operations and the inability to pass an event into a function.

David Hayden uses a simple Customer class in his Custom Model Binder and More UI Validation in ASP.NET MVC post of 9/8/2008 to demonstrate the CustomModel binder’s input validation capabilities.

David Hayden’s ASP.NET MVC UI Error Handling - ModelState and AddModelError post of 9/7/2008 demonstrates validating a phone number input with ModelView’s ModelState property and the ModelState.AddModelError() method.

Miscellaneous Sessions from DevDays 2008 Amsterdam (Video, May 2008):

2 comments:

Anonymous said...

Thanks for pointing to the Persistence Ignorance (POCO) Adapter for Entity Framework V1. I'd love your in depth thoughts on this, as to when it might be a viable (future proof) solution to use. And am also interested as to whether it works with ADO.NET Data Services and the rest of the Data Strategy elements.

Roger Jennings (--rj) said...

@Andy

I asked the following question in a comment to Jarek's post:

"Does Astoria consider the POCO Adapter's EFPocoContext a first-class data source, that is, supports IQueryable and induces the Astoria runtime to provide IUpdatable.

In other words, can it be plugged into an Astoria project without adding a significant amount of code?"

But haven't yet received an answer. I expect to give it a workout later this week.