Sunday, June 29, 2008

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

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

Updated: 6/29/2008

Jeff Currier Explains How SQL Server Data Services Manages Optimistic Concurrency Conflicts with SOAP

Jeff notes that managing optimistic concurrency conflicts with SSDS’s REST wire protocol and HTTP ETags is much simpler than handling similar problems with the SOAP protocol. His Optimistic Concurrency with SOAP in SSDS post of June 29, 2008 explains the VersionMatch class with its MatchType enum that Sprint #3 added to the Scope struct.

He demonstrates how entityScopeVersionMatch.Version and entityScopeVersionMatch.MatchType combine to enable a conditional Get(entityScope) operation, as well as conditonal updates and deletions.

Jeff promises to disclose “the biggest feature of the sprint (and one of our most requested features of the service that we have now completed for sprint 3....) … shortly.”

Added: 6/29/2008 1730 PDT

David Hayden Gives the LightSpeed 2.0 Object/Relational Mapping Tool a Glowing Review

Dave’s review in his LightSpeed 2.0 O/R Mapper - New Visual Designer with Database Schema Round-Tripping and LINQ Support post of June 29, 2008 starts with this paragraph:

I was pretty impressed with the LightSpeed O/R Mapper when it was first released, but the new Visual Studio 2008 Integrated Design Surface in LightSpeed 2.0 makes it really easy to develop and maintain domain models from a database. Just like with LINQ To SQL, you can drag and drop your tables from the Server Explorer onto the LightSpeed Visual Designer and have LightSpeed generate a model for you under the covers.

He also notes that v2.0 also enables round-tripping schema/model updates. You can update the database schema for model changes and vice-versa. Entity Framework only supports updating the model from the database; LINQ to SQL requires rebuilding the entire model after a database change.

LightSpeed 2.0 supports SQL Server 2005, MySQL 5, PostgreSQL 8, SQLite 3 and Oracle 9 or higher databases. Mindscape offers four LightSpeed 2.0 licenses:

  • Express (limited to eight model classes) is free
  • Standard (limited to 30 classes) US$99
  • Professional (no limit) US$299
  • Enterprise (no limit, includes source code) US$499

Added: 6/29/2008

Ian Cooper Explains the Pain Inflicted by Using LINQ to SQL in n-Tier Projects

Ian’s Architecting LINQ To SQL part 9 post of June 28, 2008 carries a “LINQ To SQL with N-Tier: Why is there pain?” subtitle. He cites Jon Kreuger’s LINQ to SQL In Disconnected/N-Tier scenarios: Saving an Object post of February 10, 2008 and Rick Strahl’s LINQ to SQL and attaching Entities post of August 12, 2007 as example of the pain.

Ian notes that you can serialize EntitySet and EntityRef collections with the NetDataContractSerializer, which the Entity Framework uses but LINQ to SQL embargos, but the DataContext isn’t serializable because it “contains non-remotable resources like a Db connection.” Ian continues:

This means you cannot gain change tracking and lazy loading by simply serializing your DataContext too. This tends to throw people who come from a DataSet background who have become used to serializing the context with the data. Indeed this ability to work in a disconnected fashion is trumpeted as a feature of the DataSet. As a result, this set of users tries to use LINQ to SQL in the same way and then becomes frustrated when they can’t.

Ian proposes a message-based system to eliminate the need to serialize entities, which requires referencing the domain model across tiers:

We should share schema not type. We want to send message[s] not transfer an instance of a type.

He then shows examples of two messages for a “trivial service.” Hopefully, part 10 will continue with a sample implementation of messaging to update entities of a less trivial service.

Added: 6/28/2008

Steve Naughton Fixes a Table-Name Problem in His Database Based Permissions Project

His DynamicData: Database Based Permissions - Part 5 post of June 28, 2008, subtitled “Oops! Table Names with Spaces in them and Pluralization,” fixes a problem that arises when you add the Order Details table and moves a substantial amount of code to the Global.asax file.

The post contains links to sample code with SQL Server 2005 and 2008 tables.

Added: 6/28/2008

Charlie Calvert Returns to the LINQ Farm Series with Posts on Lambdas and Extension Methods/Scoping

Two months have gone by since Charlie’s last LINQ Farm post (LINQFarm: Understanding IEnumerable<T>, Part I, April 28, 2008). He incremented the tutorial on June 28, 2008 with these two posts:

  • LINQ Farm: Lambdas compares “two ways of creating a delegate instance, and explain[s] how they map back and forth.”
  • LINQ Farm: Extension Methods and Scoping suggests that you “always place your extension methods in unique namespace separated from the rest of your code so that you can easily include or exclude the extension methods from a program.”

As usual, there’s good advice in both episodes.

Added: 6/28/2008

Alex James Writes a Detailed Analysis of the Computed Properties Feature for Upcoming Entity Framework v2

Alex’s Computed Properties One Pager of June 27, 2008 is a detailed examination of the proposed Computed Properties feature of EF v2. This feature is intended primarily to support EDM-based reporting services.

The plan is to support computed scalar singletons, scalar collections, and, ideally, “a collection of ComplexTypes, Entities and perhaps even RowTypes.” However, Alex notes that “Random projections (i.e. RowTypes) are much more difficult.”

Added: 6/28/2008

Eugenio Pace Adds a Virtual Earth GeoRSS Property to His LitwareHR SSDS Project

In LitwareHR and GeoRSS of June 27, 2008, Eugenio describes a new library that enables his LitwareHR SQL Server Data Services (SSDS) project to geo-enable open jobs with coordinates from the Virtual Earth.

After providing the RSS feed to include the geotags and adding the JobsMap page, and modifing the AddPosition page to include coordinates, Eugenio concludes:

There’s still some work to be done on the layout and general UI, but the basics are there. I’m planning to upload the whole LitwareHR solution to CodePlex TFS soon and all these additions will go with that, so stay tuned.

Added: 6/28/2008

Suggestions for Scott Hanselman’s Updated Northwind Sample Database

Scott’s not a fan of Northwind, but when he suggested a new replacement for Northwind in his Community Call to Action: NOT Northwind post of May 29, 2008, many developers pushed back in the 82 comments to his post.

His NotNorthwind - Update #1 - All Your Northwind Are Belong To Us post chronicles the “steering committee” decision:

We had a SkypeCast call today at noon and it was agreed that Northwind does have some redeeming qualities. It's simple, it works, it's understood and there's a pile of demos written against it. We rethought the requirements.

As a small group, we've decided to extend Northwind. We'll still call it NotNorthwind (although Super Northwind 2000 and "Microsoft Visual Northwind Enabler SP2 RC0 Beta1 July Refresh Plus Pack" were also possibilities), though, but we want to add a bunch of features that should make it a more interesting database for demos/prototyping/experimenting.

My Suggestions for Scott Hanselman’s Updated Northwind Sample Database post of June 27, 2008 lists 11 additions that I’d like to see a new “Southwind” sample database implement.

Added: 6/27/2008 1245 PDT; Fixed missing paragraphs: 6/27/2008 0730 PDT

Jimmie Bogard Refactors a Layered LINQ to SQL Project to Achieve Separation of Concerns, Testability, and Dependency Inversion

There are few concrete examples of how to achieve true separation of concerns with an LINQ to SQL (or Entity Framework) project. The first three episodes of Jimmie’s journey through a refactoring exercise on a sample application from a recent edition of ASP.NET PRO magazine appear to fill that void:

Part 3 extracts a dependency on the static DataContext to facilitate testing and implements the Repository pattern for the Customers entity set The promised Part 4 will implement dependency inversion and unit tests.

Note: Jimmie didn’t identify the article, but it looks to me that it’s Bilal Haidar’s “LINQed and Layered” piece from the June 2008 issues, which you can read from the PDF version here.

Added: June 27, 2008 1245 PDT

“Connect Enterprise Apps With Hosted BizTalk Services” Article by Aaron Skonnard and Jon Flanders on MSDN

Aaron’s My latest article on BizTalk Services post links to MSDN Magazine’s June 2008 issue and his article about BizTalk Services. He observes in the “BizTalk Services SDK” section:

The BizTalk Services SDK is a free download available from that will enable you to get started programming against ISB. Before you can get started, you'll need to install the BizTalk Services SDK and create a user account on the BizTalk Services site. BizTalk Services is built on Windows Communication Foundation (WCF). The SDK is just a set of assemblies built on the Microsoft .NET Framework 3.0 that allows you to use ISB via the WCF programming model.

The Internet Service Bus (ISB) is a Microsoft hosted service, similar in concept to SQL Server Data Services (SSDS). How SSDS, ADO.NET Data Services (Astoria), or both might integrate with ISB in the future is a question I’ll be exploring during the next couple of months.

Added: June 27, 2008 1245 PDT

Mike Kaufman Continues his EDM Tools Series with Model Validation and Generating Views

Mike’s EDM Tools | Options (Part 3 of 4) post of June 26, 2008 covers “Model Validation” and “Generating Views” topic. The final topic will be combining the code from the preceding posts into the EdmGen2.exe command-line tool.

Added: June 27, 2008 1245 PDT

SQL Server Data Services Needs an Open Development Process Similar to that for ADO.NET Data Services and Entity Framework

Soumitra Sengupta’s Philosophy behind the design of SSDS and some personal thoughts post of June 27, 2008 explains SSDS’s total lack of relational features (or some might say “baggage”) in its present incarnation. Soumitra says:

Since we made an early decision to limit the number of hard problems we needed to solve, we decided that we would focus less on the features of the service but more on the quality of the service and the cost of standing up and running the service.  The less the service does we argued, the easier it would be for us to achieve our objectives. [Emphasis added.]

My SQL Server Data Services Needs an Open Development Process Similar to that for ADO.NET Data Services and Entity Framework post of June 27, 2008 suggests that the SSDS team take a different approach.

Added: June 27, 2008 1245 PDT

Ryan Dunn Continues His SQL Server Data Services and Objects Series: Part 2

In Working with Objects in SSDS Part 2 of June 26, 2008, Ryan continues from Working with Objects in SSDS Part 1 and Serializing Objects in SSDS to accommodate relationships between entities because SSDS doesn’t support associations (yet). He creates “flexible” entities with a Dictionary<string, object> property called PropertyBucket to accommodate the added associations.

Hopefully, the SSDS team will add support for associations in one of their future “sprints.” (The sooner the better.)

Added: 6/26/2007 1700 PDT

David Robinson Wants You as an SSDS Beta User

Dave’s Still waiting for your golden ticket? post of June 26, 2008 says:

[W]e are ratcheting up the speed at which we add people. We are adding hundreds and hundreds each day. If you want to start testing the most powerful, cloud based, data and query processing service now is the time to sign up. In a couple short weeks we will be rolling out our Sprint 3 bits and there is a great deal of functionality coming.

I hate to flog a dead horse, but I’m still not seeing much SSDS-related activity in the SQL Server Data Services - Getting Started forum. However, there are plenty of off-topic posts about SQL Server 2005+.

Note: My cover story about SSDS for Visual Studio Magazine’s July 2008 issue will be on-line in less than a week. It includes sample code for uploading, querying and updating the original Northwind database to a single container or container per table model.

Added: 6/26/2008 1330 PDT

Ian Cooper Rings in with a Level-Headed Critique of Entity Framework v1

Ian Cooper was one of LINQ to SQL early proponents and Entity Framework detractors. This post points to his The criticism of the Entity Framework is not just around Domain Driven Design post of June 26, 2008 and includes links to his earlier posts about LINQ to SQL and EF. There’s also a link to my early recommendations to the ADO.NET team for EF.

Get the the link with the complete backstory and links to Ian’s LINQ to SQL tutorials in Ian Cooper Rings in with a Level-Headed Critique of Entity Framework v1.

Current Commentary About the “ADO.NET Entity Framework Vote of No Confidence” Manifesto

This is list of some of the more interesting posts about Scott Bellware’s ADO .NET Entity Framework Vote of No Confidence petition moved to a separate post of the same name on June 26, 2008 at 1600 PDT because of its length.

Marcin Dobosz Lists New Features in the “Dynamic Data Features” June 25, 2008 Update

Wonder what “Dynamic Data Features” is? It’s the new alias for “Dynamic Data Extensions,” a name that lasted just 10 days. Read all about its features updated since last week in Marcin’s Dynamic Data Features 6/25 update posted post of June 25, 2008.

Don’t be put off by the 6/17/2008 date on CodePlex’s main ASPNET page. The 6/25/2008 update appears here.

Mike Taulty Posts Code to Automatically Set Timestamp Fields in Entity Framework to Concurrency=Fixed

Mike notes in his Entity Framework - Timestamps and Concurrency post of June 26, 2008: If your SQL Server tables have timestamp fields, they’re undoubtedly present to participate in concurrency conflict management, so the EF runtime should have set their Concurrency property value to Fixed.

It doesn’t, so Mike provides code to handle the task automatically.

Mike Amundsen Posts Sample SQL Server Data Services Proxy Server and AJAX Web Client Apps

You can download the two-part project from Mike’s Web site. Mike says:

I think this pattern (SSDS web proxy + clients) is going to be a pretty common model. It has the advantage of not requiring all clients to know the credentials for the SSDS repository. However, it has the disadvantage of using a proxy through which all requests are made (kinda kills the scalability a bit, eh?).

Details are in his Posted An Example for comments thread in the SQL Server Data Services (SSDS) - Getting Started forum.

Justin Etheredge Continues His LINQ Expression Trees Series: Part 2

Justin’s Dissecting Linq Expression Trees - Part 2 post of June 24, 2008 provides the best illustrated explanation of the Visitor pattern for LINQ expression trees that I’ve seen so far.

Liam Cavanaugh Explains How to Take Advantage of SQL Server 2008’s Change Tracking Feature

Liam’s Using SQL Server 2008 Integrated Change Tracking to Optimize Data Synchronization post of June 25, 2008 shows Katmai’s Configure Data Synchronization dialog that “enables SQL Server to track data changes to your database rather than relying on you to create a change tracking technique.”

Liam notes that:

DBA's are less th[a]n enthusiastic when you tell them that in order to track changes, they will need to add triggers to each of the tables.

However, management usually is less than enthusiastic about paying upgrade bills. (SQL Server 2008 Express has change tracking, but not change data capture.)

Shawn Wildermuth Recommends Silverlight for Line of Business Applications Outside the Firewall but XBAP for Intranets

Shawn’s Silverlight and Line of Business Applications post of June 25, 2008 points to his geekSpeak Webcase on the topic but includes a length explanation of his position, including:

For my money, the real benefit in Silverlight is for applications that cross the firewall. This means Line of Business applicaitons are really for B2B and B2C solutions. Unfortunately, what I hear from the community is that people see Silverlight as a solution for porting their desktop and traditional 3-tier applications to the web. Is this a good idea? I don't think so. The problem is that desktop development usually involves business objects that tend to have a direct connection to the database. Moving these sorts of applicaitons to the web means that you need to create an extra layer of communications and serialization. There is a cost both in development and performance for these extra layers.

Three of My Cover Stories are Among the Top 10 Most Popular in Visual Studio Magazine This Year (So Far)

From the Self-Promotion and Swelled-Head Department: The Redmond Media Group’s .NET Insight newsletters for June 19 and June 26, 2008 listed my following cover articles for VSM among the top 10 most popular of all articles this year (to date):

2) Model Domain Objects with the Entity Framework (March 2008)

Microsoft's ADO.NET Team readies Entity Framework and Tools 1.0 for release as a VS 2008 add-in with enterprise-level features that LINQ to SQL doesn't offer -- domain object modeling, flexible inheritance techniques, multiple database vendors, and do-it-yourself n-tier deployment.

"Do-it yourself n-tier deployment" refers to Daniel Simmons' Entity Bag (Perseus) project, which is covered by a sidebar.

3) Visual Studio 2008 Kicks Off (January 2008)

Find out how VS 2008's greatly expanded feature set and new .NET Fx 3.5 namespaces can boost your career as a professional developer and add to your programming enjoyment.

Additional VS 2008 articles in the January 2008 issue:

7) Manipulate Data in the Cloud with ADO.NET (May 2008)

ADO.NET Data Services (formerly code-named "Project Astoria") delivers data from relational tables and Windows Live services to Web mashups and Visual Studio 2008 projects, including ASP.NET AJAX and Silverlight 2.0 rich Internet applications, as Representational State Transfer (REST) resources over HTTP in response to URI-based requests or LINQ to REST queries.



Sebastien Lambla said...

The personal attack is quite unnecessary. See my respone on Julia's blog.