Friday, January 16, 2009

LINQ and Entity Framework Posts for 1/12/2009+

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

Update 1/16/2009 2:00 PM PST Substantial additions
• Update 1/15/2009 1:00 PM PST Several additions

Entity Framework and Entity Data Model (EF/EDM)

•• Tony Sneed explains how to use Visual Studio 2008’s built in Text Template Transformation Toolkit (T4) to generate POCO entity code for Data Transfer Objects (DTOs) in his T4 POCO Templates for L2S and EF. Tony’s T4 templates continue the trend started by Damien Guard and Danny Simmons toward code-generation with T4 templates for data-driven projects.

•• Jim Wooley’s Changing the Namespace on generated Entity Framework classes of 1/15/2009 explains how changing the namespace of Entity Framework entities differs from the same operation with LINQ to SQL.

Jim also reported a Windows 7 bug with the EF and LINQ to SQL graphic designers in his Win7 and the LINQ to SQL and LINQ to Entity designers post of 1/15/2009.

• David McCarter will present the Building nTier Applications with Entity Framework Services session to SoCal Code Camp – Fullerton on 1/24/2009 at 11:15 AM in room H 123 on the Cal State Fullerton campus. Here’s the description:

Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!

David Pallman will present four Code Camp - Fullerton sessions on Widows Azure:

  1. Sat 11:15 AM: Azure Cloud Application Mode
  2. Sat 1:15 PM: Azure Cloud Storage
  3. Sat 2:30 PM: Azure Cloud Security
  4. Sat 3:45 PM: Azure Cloud App Demo: Social Networking Web Site

• Alkampfer’s Entity Framework first steps post of 1/8/2009 attempts to clarify new EF users’ confusion with LINQ [to Entities], Entity SQL, Entity Framework, and deferred query execution terminology.

Simon Segal continues his Entity Framework Repository, Specifications and Fetching Strategies series in this 1/13/2009 post:

Most recently I also made it clear that I felt the idea of Fetching Strategies was (for now) a waste of time (in the Entity Framework) but I have (as promised) reworked the earlier code libraries I posted for LINQ To SQL. The libraries contain a base / generic Repository and base Specification that can be utilised in building more specific Repositories (ala DDD) and the specifications are useful in building dynamic queries and testing for entity equality.

I have also decided that another amendment should be made as to my original intent and therefore not pursue a single library to support both Microsoft ORM products and thus leave them as separate.

Download the source code.

Justin Etheredge’s Making the Entity Framework Fit Your Domain - Part 2 post of 1/12/2009 continues his quest to use EF in domain-first design mode with POCOs and the IEntityWithKey, IEntityWithChangeTracker and IEntityWithRelationships interfaces. According to Justin, “The last interface ‘IEntityWithRelationships’ requires a bit more work to get implemented,” so he’s leaving that implementation to his next post on the topic.

The Entity Framework Design Team’s Update on Computed Properties post of 11/12/2009 outlines the intention to replace computed properties with Model Defined Functions, which the team described last week. The team concludes:

We think our best course of actions in the short term is 1) to focus on supporting Model Defined Functions and 2) ask for your feedback on the relative importance of Computed Properties given the points listed above.

LINQ to SQL

•• Tony Sneed explains how to use Visual Studio 2008’s built in Text Template Transformation Toolkit (T4) to generate POCO entity code for Data Transfer Objects (DTOs) in his T4 POCO Templates for L2S and EF. Tony’s T4 templates continue the trend started by Damien Guard and Danny Simmons toward code-generation with T4 templates for data-driven projects [copied from the “Entity Framework and Entity Data Model (EF/EDM)” section].

•• Jim Wooley’s Changing the Namespace on generated Entity Framework classes of 1/15/2009 explains how changing the namespace of Entity Framework entities differs from the same operation with LINQ to SQL [copied from the “Entity Framework and Entity Data Model (EF/EDM)” section].

Jim also reported a Windows 7 bug with the EF and LINQ to SQL graphic designers in his Win7 and the LINQ to SQL and LINQ to Entity designers post of 1/15/2009.

David Hayden’s O/R Mapper Identity Generation via KeyTable - Reduce Roundtrips and Improve Performance post of 1/14/2009 laments that LINQ to SQL doesn’t support a Key Table (Fowler, Martin, Patterns of Enterprise Application Architecture, p. 222) that supplies identity field values for object IDs (primary key values of persistence tables).

The LightSpeed O/RM tool supports key tables, so Dave uses it to demonstrate how these relatively uncommon objects improve performance by reducing database roundtrips. If the Data Programmability team has some spare resources to upgrade LINQ to SQL in ADO.NET 4.0, support for key tables might be a good investment.

Luca Bolognese posted Expression tree serialization code posted on Code Gallery, which contains

A wrapper for serializing/deserializing LINQ to SQL queries: A wrapper around the expression serializer allows serializing LINQ to SQL queries and de-serializing into a query against a given DataContext.

on 11/20/2008, but I missed it.

LINQ to Objects, LINQ to XML, et al.

•• Nikhil Kothari’s DomainDataSource ServerControl post of 1/15/2009 describes a custom ASP.NET server control that replaces the LinqDataSource when you want to:

write an honest-to-goodness complete LINQ expression without learning a DataSource control-specific syntax. Furthermore, [you]'d like to get the goodness of ObjectDataSource and have the data source work against some business logic rather than directly against the DataContext or the DAL.

Nikhil is a software architect in the .NET Developer Platform group within Microsoft’s .NET Developer Division.

ADO.NET Data Services (Astoria)

•• Beth Massi shows you how to build a WPF client for an ADO.NET Data Service based on the Entity Framework in her ADO.NET Data Services - Building a WPF Client post of 1/15/2009.

Andy Conrad’s Timeout Workaround post of 1/13/2009 admits to a bug in the ADO.NET Data Services client (System.Data.Services.Client.dll) that the team shipped with .NET 3.5 SP1 and the Silverlight 2.0 SDK:

[W]e do not throw the correct exception when a HTTP request has problems while being sent to the server.  I.e. a request timeouts, there is a bad server name, etc.  In other words, any problem that would normally raise a System.Net.WebException.  Unfortunately, in V1 of ADO.NET Data Services a NullReferenceException is raised instead of a WebException and even worse, the exception message is lost. …

We are planning on fixing this bug in a future version of ADO.NET Data Services client (both in .NET and Silverlight) so if your code relies exclusively on catching the NullReference exception, it will be broken when we ship the fix.  Hence, to make your code robust – have your code explicitly catch both exception types.

Andy includes sample code for the workaround.

John Papa’s Manipulating Service References in Silverlight 2 post of 1/13/2009 points out:

The [technique described by Shawn Wildermuth here] can be adapted for Astoria by flipping the service reference’s context object’s instantiation as shown [in the sample code provided.]

Shawn Wildermuth describes Controlling Service References in Silverlight 2 when changing Web service endpoints in this 11/8/2009 post.

ASP.NET Dynamic Data (DD)

Steve Naughton’s Dynamic Data – Default Value in ForeignKey Edit FieldTemplate post of 1/14/2009 explains “how to get the DefaultValueAttribute to affect the ForeignKey Edit FieldTemplate.

SQL Data Services (SDS) and Cloud Computing

This topic moved on 1/3/2009 to Azure and Cloud Computing Posts for 1/5/2009+.

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

Gil Fink provides aid in Deciding When to Use ASP.NET MVC Framework instead of ASP.NET Web forms with this 1/16/2009 post.

Gil Fink’s Extending ASP.NET MVC HtmlHelper Class post of 1/13/2009 shows “an example of how to extend the ASP.NET MVC HtmlHelper class that you can use within your MVC views.”

John K. Water’s Microsoft Releases CTP of VS Extensions for SharePoint post of 1/12/2009 for Redmond Developer News describes:

The new Visual Studio 2008 extensions for Windows SharePoint Services (VSeWSS), released as version 1.3, are templates for creating, debugging, packaging and deploying SharePoint projects. This release includes templates for Web Parts, Data Lists, Content Types, Event Receivers and Modules, among others.

The SharePoint Team announced the v1.3 CTP in its Announcing: Community Technology Preview of Visual Studio 2008 extensions for SharePoint v1.3 post of 1/12/2009.

The preceding announcement is undoubtedly related to the topics of Mary Jo Foley’s Select testers to get Office 14 alpha release any day now and A new member of the Office 14 family: Office for Sales posts of 1/13/2009. Office for Sales is based on SharePoint and probably will be available for SharePoint Online.

0 comments: