Sunday, July 06, 2008

LINQ and Entity Framework Posts for 7/2/2008+

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

Updated: July 4, 2008 1633 PDT: Additions; July 5, 2008 Updates, July 6, 2008 Additions

Soumitra Sengupta: SQL Server Data Services is Built on SQL Server 2005 SP2, not 2008

In an update to his Roger Jennings talks about SSDS in a Visual Studio Magazine Article post of July 2, 2008, Soumitra adds the following in response to a question I posed:

I thought Dave Campbell in one of his press interviews had mentioned it but I could not find the reference.  Sorry Roger.  So here is an answer to your question - SSDS is built using SQL Server 2005, SP2 as the starting code base.  That is the starting point and we made changes to it.  Over time, some of these changes will make its way into the SQL Server mainline and SQL Server 2008 will make its way into SSDS.  We wanted to proceed in parallel as fast as we could and this was the best way to do it.

I found a reference to SQL Server 2005’s use with SSDS in SQL Server Data Services: Good news, bad news for partners of March 14, 2008 by Barbara Darrow (at MIX 07):

The services are based on the current SQL Server 2005 release. SQL Server 2008 is due later this year.

Apparently she was quoting Niraj Nagrani, senior marketing manager for SQL Server.

This means that references to SQL Server 2008 and its features in my “Test-Drive SQL Server Data Services” cover article for the July 2008 issue of Visual Studio Magazine are misleading. Sorry about that; mea culpa. The fact that “SQL Server 2008 will make its way into SSDS” ameliorates the error somewhat.

Jamie Thompson Analyzes Query Resultset Paging by SQL Server Data Services

SQL Server Data Services (SSDS) batches query resultsets that return more than 500 entities. Jamie’s SSDS: I'm gonna get 500 results and then I'll get 500 more... post of June 27, 2008 answers several common questions about the paging process.

Note: If you’re wondering why SSDS posts qualify for inclusion in this blog, here’s the answer:

  • SSDS uses a LINQ-like query language (but supports only a few LINQ Standard Query Operators)
  • SSDS schemas will use the Entity Data Model when schemas are enabled later this year. Use of the entity data model will make implementing the promised on-premises SSDS clone practical.

Shawn Wildermuth Continues His IUpdatable Implementation for NHibernate Project

As Shawn observed in the first member of this series, Implementing IUpdatable (Part 1) of July 1, 2008:

[O]nly the Entity Framework currently support[s] the IUpdatable interface (and [it] is in fact implemented inside of ADO.NET Data Services not directly in Entity Framework).  This means that DataSets and LINQ to SQL do not support it either.

IUpdatable is a member of the System.Data.Services namespace, which VS 2008 SP1’s System.Data.Services.dll provides. The Project Astoria Team Blog’s IUpdatable & ADO.NET Data Services Framework post of April 10, 2008 provides more information on the IUpdatable interface.

In his Implementing IUpdatable (Part 2) post of July 4, 2008, Shawn finds NHibernate’s “type information to be more complete and faster” than his cached reflection data, so he refactors his GetResource() and CreateResource() method calls and completes the easy parts with GetProperty() and SetProperty().

He promises to deal with the “hard parts” in his next post.

(Shawn has “been looking at the story around non-Entity Framework models through a Data Service and thought that NHibernate through a Data Service would be a great example” for a forthcoming article about Silverlight 2 and ADO.NET Data Services.)

Added: July 4, 2008 1630 PDT Updated: July 5, 2008

Nigel Ellis: Role-Based Authorization Plans for SQL Server Data Services

SQL Server Data Services (SSDS) relies on Secure Socket Layer (SSL) v3 encryption to secure an authority’s user ID and password for authentication, as well as to protect data transfer from exposure by interception. Delegated authorization is required to restrict additional authenticated users to read-only or read-write access. Several potential SSDS testers (including me) have requested (but not received) details on plans for implementing role-based authorization.

Channel9’s Istvan Cseri and Nigel Ellis: SQL Server Data Services Architecture interview by SSDS evangelist Ryan Dunn posted April 7, 2008 contains quite a bit of useful (and previously unpublished) information about SSDS architecture. My Nigel Ellis Says SQL Server Data Services Will Use the Entity Data Model For Schemas post of July 3, 2008 is a transcript of Nigel Ellis’s comments about SSDS’s future schema model.

My Nigel Ellis Discusses Role-Based Authorization Plans for SQL Server Data Services post of July 4, 2008 contains a transcript I made of Nigel’s remarks about SSDS security. The transcript starts at 00:31:05, immediately following the schema discussion.

Added: July 4, 2008 1111 PDT

Mike Amundsen Posts Sample SQL Server Data Services Provisioning Application

Mike’s New Provisioning Client Example Web App thread of July 4, 2008 in the SQL Server Data Services (SSDS) - Getting Started forum includes a link to the SSDS Provisioning Client Web service that lets you manage authorities, containers, and entities.

My Mike Amundsen Posts Sample SQL Server Data Services Provisioning Application post includes a couple of screen captures for those of you without an SSDS beta account.

Added: July 4, 2008 1105 PDT

Stefan Tilkov’s REST Anti-Patterns Essay

InfoQ’s blurb for this article offers a brief description of Stefan’s REST Anti-Patterns essay of July 2, 2008:

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

If you’re using REST protocols with SQL Server Data Services or ADO.NET Data Services, this article is a must-read. 

Added: July 4, 2008 1105 PDT

Vote for Mike Taulty as Computer Weekly’s King of Programming and Technical Blogs

Click the screen capture at Mike’s Outrageous Self-Promotion :-) post of July 3, 2008.

Added: July 3, 2008 1700 PDT

Julie Lerman’s Software Development Meme

Julie says about her DevSource Software Development Meme post of July 3, 2008:

There's a new meme going around the blogs and I've been called out by Shawn Wildermuth to participate - it's the "my programming career" questionnaire. My history is not quite as illustrious as Shawn's when it comes to programming, but I do have a few very unique skeletons in my closet!

Added: July 3, 2008 1700 PDT

Frans Bouma Continues LINQ to LLBLGen Pro Feature Highlights Series

In Linq to LLBLGen Pro: feature highlights, part 2 of July 3, 2008 Frans continues from where he left off in Linq to LLBLGen Pro: feature highlights, part 1 with a discussion of:

  • Exclusion / inclusion of entity fields in a query
  • Hierarchical fetching of entity graphs using Prefetch Paths

This post is recommended reading for the ADO.NET team’s EF program managers and developers.

Added: July 3, 2008 1700PDT

David Robinson: SQL Server Data Services Article in MSDN Magazine’s July Issue

Develop Robust and Scalable Apps with SQL Server Data Services” is a lengthy article by SSDS evangelist Dave Robinson for MSDN Magazine’s July 2008 issue that covers these topics:

  • The SSDS data model
  • Managing entities, containers, and authorities
  • Creating a sample Web application
  • Class serialization and deserialization

Coverage is about the same as that of my article.

Added: July 3, 2008 1700 PDT

John Papa: n-Tier Architecture for Entity Framework with WCF and an MVC Site with a WPF Presentation Layer in MSDN July Issue

John’s Using the Entity Framework in a Layered Architecture post of July 3, 2008 points to his “The Entity Framework In Layered Architectures” article for MSDN Magazine’s “DataPoints” July 2008 column. The article includes downloadable code for a Northwind-based demonstration site that uses WPF forms for views of a ASP.NET MVC site.

Updates require updating the table each time an entity is added, updated, or deleted because the ObjectContext can’t be serialized. Inability to serialize the ObjectContext prevents accumulating changes in a disconnected fashion and applying them all at once with a SaveChange() invocation.

Replacing “Layered” with “Tiered” would improve the post and article titles’ accuracy.

Added: July 3, 2008 1300 PDT

Nigel Ellis: Entity Data Model Schemas Coming for SQL Server Data Services

My Nigel Ellis Says SQL Server Data Services Will Use the Entity Data Model For Schemas post of July 3, 2008 includes a partial transcription from Channel9’s Istvan Cseri and Nigel Ellis: SQL Server Data Services Architecture interview by SSDS evangelist Ryan Dunn.

The transcription covers Nigel’s commentary about the schema feature coming in a future version of SSDS.

Added: July 3, 2008 1300 PDT

Steve Naughton Codes ASP.NET Dynamic Data’s Missing FileImage_Edit FieldTemplate

His Dynamic Data: FileImage_Edit FieldTemplate post of July 3, 2008 offers two alternatives for the missing FileImage_Edit FieldTemplate:

  1. Get a list of images from the specified folder [ImageUrl("~/images/{0}.png")] and let the user choose
  2. Let the user upload the file to the [ImageUrl("~/images/{0}.png")] folder and the pass the filename to the DB field.

Scott Hanselman Shows How to Take Advantage of XML Literals with ASP.NET MVC

Scott’s The Weekly Source Code 30 - VB.NET with XML Literals as a View Engine for ASP.NET MVC post of July 2, 2008 uses VB’s LINQ to XML literals to generate XML lists for an MVC editlink class. (Of course, all other .aspx pages used C# in the codebehind.)

You also can watch the XML Literals Panel from TechEd 2008 video on a similar topic.

Added: July 3, 2008 1300 PDT

Marcin Dobosz Posts ASP.NET Dynamic Data July 2 (2008) Update

His Dynamic Data Futures 7/2 update posted item of July 2, 2008 lists the new features added to the Dynamic Data Futures section on CodePlex:

  • Added DynamicHyperLink control. It generates links to Dynamic Data tables for all actions and works both in data-binding and declarative scenarios. 
  • Added Url and EmailAddress field templates. 
  • Modified ForeignKey_Edit field template to display a [Not Set] entry for required columns in insert mode. Added a RequiredFieldValidator to ensure that an entry is selected if the column is required.
  • Modified routes in Global.asax to generate pretty URLs using the new PrettyDynamicDataRoute.
  • Changed FilterAttribute.Order property to match the behavior of ColumnOrderAttribute.Order property. Now each filter has a default Order of 0; negative numbers can be used to push filters to the front, while positive numbers can be used to push filters to the back.

Added: July 3, 2008 1300 PDT

Ryan Dunn Completes a REST Library for CRUD Operations on SQL Server Data Services

The default SQL Server Data Services page on MSDN promises in it’s “Application Agility” section that:

A rich client library in C# or VB providing LINQ query support will be available.

So far, no such “rich client library” has appeared. However, Ryan Dunn is rolling his own client API for REST library in his “Working with Objects in SSDS” series. His Working with Objects in SSDS Part 3 post of July 2, 2008 completes the library by adding querying capability with an expression tree and expression visitor, as well as paging.

Sample code is available from the MSDN Code Gallery.

Added: July 3, 2008 1300 PDT

Shawn Wildermuth’s New Blog Uses Entity Framework as the Data Source and the ASP.NET Routing Framework Instead of .aspx Links

Shawn says in his Links and New Site Technology post of July 2, 2008, the first on his new blog that replaces adoguy.com:

The use of the Entity Framework and LINQ was pretty straightforward. I used LLBLGen Pro in my old site to do the data access and it held up great.  I only switched so I could test out the Entity Framework on a production-ish system, not because of any limitations in the old code. Creating a model with the Entity Framework was a snap. My data is not complicated so I didn't have any complex scenarios.  The only thing I did do was change the collection names from singular to plural. Being able to use LINQ to do my queries, search and paging was just spectacularly useful. I am completely in the LINQ camp now.

ASP.NET Dynamic Data also uses the new routing library.

Added: 7/2/2008 1740 PDT

“Test-Drive SQL Server Data Services” Article Published

My “Test-Drive SQL Server Data Services” cover article for the July 2008 issue of Visual Studio Magazine is available from the above link or by clicking the cover image.

Here’s the deck: Microsoft readies its new "cloud database" by hosting beta versions of REST and SOAP protocols for performing CRUD operations on clustered, customized SQL Server 2008 instances. These instances are organized as massively scalable, super-reliable, highly available Web services.

My “Test-Drive SQL Server Data Services” Article Published post of July 2, 2008 has more background data about the article, sample code, and an interesting question about the architecture of SSDS.

Ian Cooper Requests the Data Programmability Group to Increase Support for LINQ to SQL

Ian is just one of a number of independent .NET developers who recommend LINQ to SQL as the better choice for object-oriented data-intensive .NET applications. He concludes his Showing some support for LINQ to SQL post of July 2, 2008 with:

Today, while I would not recommend using the Entity Framework I would recommend looking at LINQ to SQL. Everything needs evaluation for your own needs, but unlike EF, LINQ to SQL is a better contender for OO approaches today.

Sasha [Goldshtein] points out when looking at how LINQ to SQL is suprising people who had been misinformed as to what if offered and how we should use it, the noise in the blogsphere from Entity Framework supporters seems to have drowned out the value of LINQ to SQL as an ORM. Indeed I believe the Data Team's own pitching of LINQ to SQL as a RAD tool is an underestimates the product.

As I mentioned in my “Sasha Goldshtein Believes LINQ to SQL is Under-appreciated” topic of my LINQ and Entity Framework Posts for 6/30/2008+ post, it’s my opinion that:

  • Microsoft’s SQL Server Data Programmability (DP) group is fully committed to Entity Framework as its data platform going forward
  • The DP group is in the process of deprecating LINQ to SQL by not-so-benign neglect.

Mike Taulty Substitutes Entity Framework for LINQ to Entities in His Concurrency Management Analysis

In On Entity Framework, Concurrency of June 2, 2008, Mike tackles the same issues for EF that he handled for LINQ to SQL in his On LINQ to SQL, Concurrency and Timestamps post of July 1:

[H]ow we can detect concurrency problems with Entity Framework in order to ensure that when we submit changes to the DB we first;

  1. Present the user with a list of all the concurrency errors in one go
  2. Present the user with their changes versus the DB's current data
  3. Ask the user how to go about resolving each issue
  4. Repeat until all the changes get to the DB one way or another

Similar (but not identical) problems occur for transaction rollback with both data providers.

Simon Segal Implements the Specification Pattern for LINQ to Objects and LINQ to SQL with Dependency Injection

Simon’s LINQ to SQL, the Specification Pattern and Dynamic Queries post of July 2, 2008 begins:

I have just finished working on an implementation of the Specification Pattern that will work with LINQ (to objects) using Lambdas to provide the test logic and in the case of LINQ to SQL using the same testing predicates as search predicates when querying the database.

And provides a starting code snippet. He continues:

My next goal is to enable the eager and lazy loading in these scenarios dealt with by using something similar to Fetching Strategies and have the Repository load them using dependency injection which will enable me to plug in the correct fetching strategy at will.

Shortly I will post some code that demonstrates all this with a Repository and not the standard .DBML file, DataContext way of doing things as per above.

The later episodes sound interesting.

0 comments: