Monday, August 25, 2008

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

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

Updated 8/25/2008

Updated 8/24/2008

• Updated 8/22/2008

Entity Framework (EF)

•• The Domain.Net Team’s NHibernate 2.0 gold Released – Must Wait for ‘Linq to NHibernate’ post of 8/24/2008 notes that NHibername 2.0 release yesterday without incorporating LINQ to NHibernate. You must download the implementation from a new location,

Fabio Maulo’s 21 chapters of NHibernate documentation as a Google Knol offers open contribution under a .

Muhammad Mosa discovers EF’s LINQ to Entities doesn’t support many constructs that LINQ to SQL handles with no problem. His LINQ to Entities, what is not supported? post of 8/24/2008 describes the following problems when migrating the data source of Rob Conery’s sample MVC Storefront project from LINQ to SQL to Entity Framework:

    • Custom Methods & Extension Methods cannot be translated into a store expression
    • LINQ to Entities only support Parameterless constructors and Initializers
    • IEnumrable types cannot be initialized in LINQ to Entities query

You can download Moses’s project from a link on his post.

•• Matthieu Mezil finds that the orderby … descending expression produces unexpected results in his LINQ To Entities: Strange, very strange post of 8/23/2008.

Matthieu Mezil’s TPH limitation which should disappear with v2 post of 8/23/2008 describes an exception when using Is Null and IsNot Null conditions on a table-per-hierarchy inheritence model (see below) that shouldn’t happen and needs fixing in EF v2.

Matthieu Mezil discusses the use of NULL values in the type discriminator column of a table-per-hierarchy inheritance model in his TPH is more than a selection! post of 8/22/2008.

Mikael Henriksson waxes enthusiastic about EF in Entity Framework - The best thing since the wheel? of 8/22/2008. He’s using EF in a real-world project and says:

Entity Framework can't replace working within a well thought through Domain Model but it sure helps me in my everyday work. I just finished a drafting a part of our application that took month and a half to get up and running the first time (I was not involved in the first version). It took me 2 days to come up with a pretty much solid version 2 of that same part.

Mikael claims using EF reduced the 60 developer*day project to 4 developer*days (including 2 days for adding business validation rules)

Ido Flatow shows you how to change CSDL and MSL files programmatically in his Change Entity Framework storage DB schema in runtime of 2/22/2008. Changing files at runtime enables working with experimental, developmental, and production databases without the need to change and recompile your EF code.

Matthieu Mezil explains in How to have a property on ObjectContext which returns the derived entities? of 8/21/2008 how to customize the code generator to add a property for the EntitySet of an inherited property in two passes. However, this later version does the same job in a single pass.

David Yack finds that adding a type declaration for the from clause’s parameter in a LINQ to Entities expression adds a Cast<T> operator to the translated expression in his Entity Framework - Cast Affects Include post of 8/21/2008. The spurious Cast<T> operator caused his Include() method to fail. Removing the type declaration solves the problem.

ADO.NET Data Services (Astoria)

•• Dare Obasanjo’s RESTful JSON: Bringing REST and RPC Closer Together post of 8/24/2008 analyzes comments by Dave Winer and Tim Bray about Dare’s earlier Explaining REST To Damien Katz essay. Dare concludes:

If you put together the notion of service documents with using JSON as the payload format for a service endpoint, you're close to getting the touted programmer friendliness of RPC technologies like XML-RPC & SOAP/WSDL while still building a RESTful service which works with the Web instead of against it.

The only problem is how to deal with statically typed languages like C# and Java. These languages need the types of the objects that application will consume from a Web service defined up front. So if we could just figure out how to come up with service documents for JSON services that included the notion of a class definition, we could pretty much have our cake and eat it to with regards to getting the ease of use of an RPC system while building a RESTful service.

Sounds to me like an interesting development that might apply to Astoria v2 and SSDS.

Marcelo Lopez Ruiz adds another reason why you’ll probably want to use ES as Astoria’s O/RM data source, despite the performance hit when you first spin it up with a large number of objects. His EntityState problems in ADO.NET Data Service post of 8/22/2008 reports:

[I]f you are using a 'T' that's not the ObjectContext-derived type in your DataService<T>, the service won't know you're using an ADO.NET Entity Framework types, and will try to discover types and properties by following references, which eventually leads to the EntityState property problem. Using the ObjectContext type as the 'T' should then solve the problem.

Marcelo Lopez Ruiz demonstrates why the Entity Data Model is Astoria’s default data source in Metadata for ADO.NET Data Services of 8/21/2008: The $metadata resource returns a description of the data model in EDM’s Conceptual Schema Definition Language (CSDL).

Pablo Castro offers a summary history of ADO.NET Data Services in his Timeline of Project Astoria of 8/20/2008 categorized as: Idea, Hack, Pitch, Prototype, Review, Announcement, Team, Design, Release, Future. Makes interesting reading.

Alex Barnett recalls three of his Astoria experiences in How ADO.NET Data Services came to be (formerly known as Project Astoria) of 8/20/2008.

Marcelo Lopez Ruiz explains the DataServiceContext.UsePostTunneling property in POST tunneling in ADO.NET Data Services of 8/20/2008.

Scott Hanselman’s The Weekly Source Code 32- Atom, AtomPub and BlogSvc, an AtomPub Server in WCF post of 8/20/2008 provides more insight into in System.ServiceModel.Syndication and ServiceDocument in the context of the new open-source BlogSvc implementation of AtomPub that’s compatible with Windows Live Writer.

Gil Fink comments on Arnon Rotem-Gal-Oz’s Why the Database as a
Service is a Bad Idea
post in Why Data as a Service isn't a Bad Idea of 8/20/2008 and concludes:

So what is the potential of ADO.NET Data Services?
In a RIA … or data driven application it can help to provide a cleaner solution. The ability of Data Services to return responses in JSON or in URI makes them flexible and usable by Ajax or Silverlight. Also, if the data service is consumed by a .Net client you can use the LINQ to [REST] feature. The Data Services come with other features like concurrency, batch operations over HTTP, full query operation support and more. These features, when used right, can help to provide good solutions for a data driven application.

SQL Server Data Services (SSDS)

Mike Amundsen is Looking for Suggestions on Implementing One-to-Many, Many-to-Many Patterns in SSDS, according to his 8/22/2008 thread in the SQL Server Data Services (SSDS) - Getting Started forum. Hopefully, an SSDS team member will provide insight how the service will emulate joins on the client efficiently. (As I read the tea leaves, there are no plans for the service to implement joins.)

Stephen Wynkoop Challenges with Data Management in the Cloud? article from the SQL Server Worldwide Users Group ( newsletter of 8/21/2008 suggests that data stored in cloud databases …

can be accessed by serving appropriate warrants or other legal processes to the cloud provider.  In some cases, this can be done without notifying the owner of the information (such as cases where they think that by knowing, the owner could/would/might destroy information). …

Perhaps we need a system where the information stored in the cloud is done so encrypted, with keys that are owned by the information owner only.  That way the cloud provider returns to being just that, a service provider, without having responsibility (or access) for/to the data on their systems.

I believe that this is a topic that the SSDS Team should consider for implementation in v1 RTM but probably requires SQL Server 2008. (The present “CloudDB” runs on modified SQL Server 2005.)

ASP.NET Dynamic Data (DD)

Matt Berseth drills down on the use of DD’s MetadataType attribute in his Dynamic Data and Custom Metadata Providers post of 8/24/2008.

• Scott Hunter’s Image Generation is released to CodePlex post of 8/21/2008 describes the long-awaited ASP.NET GeneratedImage replacement for Whidbey’s (!) DynamicImage feature that got cut from VS 2005. GeneratedImage is an ASP.NET control that automatically generates an ImageHandler and wires the control to its URL. The new control is ideal for use in DD projects.

ImageHandler is an implementation of IHttpHandler that, according to Scott, supports:

  • Transforms (resizing, watermarks, user defined transforms)
  • Client-side caching
  • Server side caching
  • Access to parameters passed from the GeneratedImage control
  • Provide simple mechanics for returning images

• Scott Hanselman’s ASP.NET Futures - Generating Dynamic Images with HttpHandlers gets Easier post of 8/21/2008 provides examples of creating and using the GeneratedImage control.

• Matt Berseth offered yet another ASP.NET Dynamic Data - Simple 5 Table Northwind Example on 8/21/2008. He says:

I am pretty impressed and I am looking forward to exploring this further - stay tuned.

Matt Berseth being “pretty impressed” with DD bodes well for its future.

Josh Heyse uploaded Dynamic Data Filtering v1.01, which eliminates private reflection, to CodePlex on 8/20/2008. Josh says he “worked with the Dynamic Data team to open up several internal method calls to eliminate the need for the reflection.”

You can learn more about Dynamic Data Filtering, which adds:

  • Searching ranges (ListPrice > 10 AND ListPrice < 500)
  • Searching in a list of possible values (Class in (‘L’, ‘M’))
  • Partial text searching (Color LIKE ‘B%’)

to the stock DD filters, from the five-part A Richer DynamicFilterRepeater series on Josh’s blog.

Justin Etheredge’s Exploring System.Web.Routing post of 8/20/2008 is a detailed tutorial on the new URL mapping feature introduced by VS 2008 SP1 for ASP.NET MVC and DD.


••• David DeWinter requests potential users to suggest features for his LINQ to SQL utility that supports updating the object model from the database schema and property-name fixup in his DBML Fixup Preview post of 8/24/2008. David’s current feature list appears to duplicate the LINQ to SQL capabilties of Kris Andersson’s Huagati DBML/EDMX Tools. David has scheduled DBML Fixup for a year-end release.

•• Andrew Davey suggests a set of rules for creating “convention-based mapping” with LINQ to SQL’s XML mapping files to minimize manual authoring in his LINQ-to-SQL Convention Mapping Source post of 8/24/2008

• Beth Massi’s Data on the Smart Client Talk at Bay.NET UG post of 8/21/2008 provides a link to her databinding to WinForms and WPF clients presentation to the Bay.NET user group and its sample code. (The OMS.mdf database file required for the demos is in the …\LINQSQLDemo\OMSDataLayer folder.)

Jim Wooley delves into Object Identity tracking changes with LINQ to SQL SP1 on 8/21/2008 and explains that LINQ to SQL checks the cache before sending a T-SQL query to retrieve a single entity instance.

Simon Segal offers props to LINQ to SQL in The future of LINQ To SQL and showing some support of July 30, 2008 and the bumper sticker below to proclaim solidarity with the first and fastest LINQ O/RM implementation:

which links to Ian Cooper’s Showing some support for LINQ to SQL post of July 2, 2008. Ian says, in part:

I would like to see MS give this product the support it deserves. I would like to see a commitment from the Data Platform team to stop its focus on talking LINQ to SQL down as a RAD tool and tallking up its advantages for use in the OO approaches to software development. For example  I would like to see the Data Platform team talking about LINQ to SQL's support for POCO strategies, lazy loading, etc. and pointing out to customers who request those features. There needs to be more acknowledgement that if you want them you should consider LINQ to SQL.

[I missed these items when originally posted.]

LINQ to Objects, XML, et al.

••• Jim Wooley shows you how to Enable the Expression Tree Visualizer in VS 2008 in his 8/24/2008 post.

•• Damon Wilder Carr’s LINQ to Financial Markets : Optimizing Provider to Real-Time Quotes, Analytics, and Silverlight-WPF Visualization post of 8/22/2008 describes a forthcoming LINQ implementation that offers:

An easier way to consume, visualize, understand and quantify just about any information you can imagine from the world of global financial services.

  • Real-Time stock quotes to Complex Analytics of Multi-Asset Class Portfolios
  • Monte-Carlo simulation with Optional Quantitative Add-Ins
  • Efficient frontier Optimization based on Constraints you Set
  • User defined heuristics from strategic rebalancing to day-trading

Release of the new provider currently is in limbo. Damon says:

Due to the nature of the access to this information, we are still working out the details for the open-source version we plan to offer soon. The world of the owners of this data has not caught up to the philosophy we have for transparency and shared value.

•• Jim Wooley says “LINQ to Reflection isn't really a provider, but just a specific implementation of LINQ to Objects which happens to query reflection information” in his LINQ to Reflection IsNot LinqProvider post of 8/23/2008.

• Eric White’s Using LINQ to XML to Retrieve Content Controls in Word 2007 post of 8/21/2008 shows you how to write a LINQ query to retrieve the contents of Word 2007’s content controls.

Bart De Smet gets the Longest Post Title Award for What Do VB 9.0 Error “BC36593: Expression of type ‘X’ is not queryable.” And C# 3.0 Error “CS1936: Could not find an implementation of the query pattern for source type ‘X’.” Really Mean? of 8/20/2008. His essay explains in granular detail what these VB (!) and C# error messages mean.

Mike Ormond discovers in his LINQ to JSON post of 8/21/2008 that LINQ to JSON from Silverlight’s System.Json namespace saves a lot of code because he doesn’t need to define a .NET type to represent the JSON object.

SQL Server Compact (SSCE) 3.5 and Sync Services

No SSCE posts as of 11:00 PDT. 

Visual Studio 2008 Service Pack 1 (General)

Scott Hanselman’s SmallestDotNet: On the Size of the .NET Framework post of 8/23/2008 describes options for upgrading client PCs to .NET Framework 3.5 with installers that range in size from 10 MB to 56 MB, depending on the client’s current versions. Scott also describes the Client Profile:

The Client Profile is an even smaller install option for .NET 3.5 SP1 on XP. It's small 277k bootstrapper. When it's run on a Windows XP SP2 machines with no .NET Framework installed, it will download a 28 meg payload and give you a client-specific subset of .NET 3.5.  If the Client Profile bootstrapper is run on a machine with any version of .NET on it, it'll act the same as the 3.5 SP1 web installer and detect what it needs to download, then go get it.  There's more details in the Client Profile Deployment Guide.

Scott also announces his new SmallestDotNet page that executes a small chunk of JavaScript to inspect your browser’s UserAgent and determine what version of the .NET Fx is installed. The script reports the total size of the download to update to .NET Fx 3.5.

Microsoft Downloads offers the Visual Studio 2008 SDK 1.1 as of 8/20/2008:

The Visual Studio 2008 Software Development Kit (SDK) 1.1 includes tools, documentation, and samples for developers to design, build, test and deploy extensions for Visual Studio 2008 Service Pack 1. You can also use the Visual Studio 2008 SDK 1.1 to create custom tools environments based on the Visual Studio 2008 Service Pack 1 Shell.

Miscellaneous (WPF, WCF, Silverlight, etc.)

The SQL Server Worldwide User Group ( will present a .NET Virtual Conference on October 28-30, 2008. Presenters include .NET and EF luminaries such as Kathleen Dollard, Ben Hoelting, Tim Huckaby, Tim Huer, and David Yack.

Dare Obasanjo’s Some Thoughts on Amazon's Elastic Block Store essay of 8/21/2008 about Amazon’s new EBS service, which provides 1 GB to 1 TB blocks of persistent storage that you can format as a file system, concludes:

EBS is the final piece in the puzzle that had prevented Amazon's cloud computing platform from being comparable to traditional hosting solutions. With EBS Amazon is now superior to most traditional hosting solutions from a developer usability perspective as well as cost. Google App Engine now looks like a plaything in comparison. In fact, you could build GAE on top of Amazon's cloud computing platform now that the EBS has solved persistent custom storage problem.

Werner Vogels, Amazon’s CTO, announced that Amazon EBS - Elastic Block Store has launched on 8/20/2008. His post contains additional details about EBS. Vogels announced plans to create EBS in his Persistent Storage for Amazon EC2 post of 4/13/2008.