Monday, December 03, 2007

LINQ and Entity Framework Posts for 12/3/2007+

Note: This compendium is updated daily or more often, depending on availability of articles.

Scott Guthrie: ASP.NET 3.5 Extensions Due on Sunday by Monday 12/10/2007

Scott says at the beginning of his December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 post:

Several people have pinged me asking for the download location of the ASP.NET 3.5 Extensions Preview.  We were hoping to post it on the web Friday, but unfortunately found a late bug that we felt needed to be fixed.  The team is working this weekend to sign off on the new build.  We hope to be able to post it as soon as this is done - apologies for the delay.

Scott didn't mention any holdbacks, so we should be safe in assuming that all these pieces will be included:

  • ASP.NET AJAX Improvements
  • ASP.NET Dynamic Data Support
  • ASP.NET Silverlight Support
  • ADO.NET Data Services (Astoria)

He posted his article about noon on Saturday for a change. (Not in the middle of the night.)

Added : 12/7/2007

Update 12/9/2007: I asked Scott in a comment to his post: Will all five items (MVC, AJAX Improvements, Dynamic Data Support, Silverlight Support, Data Services (Astoria)) ship with this forthcoming drop? His reply:

Yes - this preview will include all of those features.

Regarding the release date, Scott said in another comment:

Sorry about the delay.  We are hoping to have the bits live early Sunday - so keep an eye out for them then.  That way you have at least half of the weekend to play with them.

The December 6, 2007 Microsoft Simplifies Data-Centric Development in Heterogeneous IT Environments press release contains this ASP.NET 3.5 Extensions preview link to the download. It 404'd as of 07:30 on 12/9/2007.

Update 12/10/2007: The preceding link is now live. See ASP.NET 3.5 Extensions Preview Released for details and a screen capture of a page generated by ASP.NET 3.5 Dynamic Data scaffolding.

How to Merge SSDL, MSL and SSDL Files into an EDMX Designer File

Courtesy of Danny Sullivan's How To: use your existing CSDL/MSL/SSDL files in the Entity Designer CTP2 post of December 7, 2007, you can read Sanjay Nagamangalam's detailed instructions for merging SSDL, MSL, SSDL and designer metadata into the single Container.edmx file introduced by Entity Framework (EF) Beta 2 and required by EF Beta 3.

Before you go through the first steps of the process, be sure to observe this warning:

NOTE: Manually edited .edmx files may not display in the designer if they have content not supported by the designer. These include Complex Types, TPC mapping, C-Side conditions, schema references (“using”), query views, defining queries, command text, unmapped abstract types, and multiple entity sets per type. Please refer to the ReadMe for more details.

Added : 12/7/2007

ADO.NET Data  Services CTP1 "Almost Here" with LINQ to Astoria, New Wire Formats, and Increased Security

Astoria PM Mike Flasko's ADO.NET Data Services == Project "Astoria" post of December 7, 2007 formalizes the name change from "Project Astoria" to to "ADO.NET Data Services" and confirms that CTP 1, which is "almost here," will support two scenarios with a pluggable data layer:

  • Exposing the Entity Data Model's conceptual view of a database to the Web with the Entity framework (the original scenario)
  • Exposing as conceptual views data from arbitrary, non-relational data sources that are accessible by an IQueryable provider with update extensions.

CTP1 also will include LINQ to Astoria for translating LINQ queries into the new URI query syntax that Pablo Castro discussed in his URI Format - Part 1 - Addressing resources using URI path segments post of September 21, 2007. (There's no Part 2).

Added : 12/7/2007

Alex James Explains How to Perform Bulk Updates with LINQ to Entities: Part 1

Entity SQL v.1.0 doesn't include DML keywords, so you must use LINQ to Entities if you want to insert, update, or delete entities rather than operate on physical rows in the persistence store (a.k.a. database) directly. To update or delete entities, you must bring the entities into memory with the appropriate LINQ query before you modify or destroy them. Alex contends that this process "seems somewhat wasteful considering you could do this in T-SQL with one very simple update statement, thereby bypassing all the query, hydration and cross process shipping costs" when performing a batch update or deletion.

In his previous post of December 4, 2007 (see below), Alex promised "to demonstrate how you can perform bulk updates with LINQ to Entities in his next post." In this post he shows about half of the process of creating a generic Update<T>() function with the following signature:

public static int Update<T>(
this IQueryable<T> queryable, Expression<Func<T,T>> updator) where T: EntityObject, new()


Alex promises to implement the Update<T>() function in his next post.

Question: Is an updator a relative of the velociraptor?

Added : 12/7/2007

Erik Meijer Compares Volta and Google Web Services for Mary Jo Foley

ZDNet Blogger Ed Burnett called Volta a late-coming Google Web Toolkit (GWT) imitation in his December 5, 2007 Microsoft creates GWT clone column, so Mary Jo Foley enticed Erik Meijer to respond. His explanation of how the two products differ is the subject of Mary Jo's December 7 Microsoft architect compares Volta and Google’s GWT post.

Erik contrasts the multi-lingual and tier-splitting capabilities of Volta with the GWT's Java-only source code input with the GWT compiler converts to JavaScript. Changing a Volta method from synchronous to asynchronous invocation only requires decorating the method signature with an [Async] attribute; doing the same with the GWT requires significant added code. Erik points out a number of other differences that favor Volta in the post.

Added : 12/7/2007

Beth Massi Does Word MailMerge the Hard Way

Beth's Mail Merging with Word, LINQ and XML Literals in VB describes how to replace Word's MailMerge Wizard with LINQ to SQL and LINQ to XML to generate the .xml part of Word .docx files.

The most interesting part of the post is her use of the Package.DeletePart() and Package.CreatePart() methods from the System.IO.Packaging namespace to refresh the .xml component of the .docx file with the correct merge data.

The System.IO.Packaging namespace contains objects and methods for creating or modifying Office Open XML, XAML, XPF, and other files that conform to the Open Packaging Conventions (OPC) specification, which is part of the ECMA Office Open XML document interchange specification (ECMA-376).

On the whole, however, I think using the MailMerge Wizard is quicker.

Added : 12/7/2007

Rick Strahl Explores LINQ to SQL C# Connection Strings

In his LINQ To SQL and the Web.Config ConnectionString Value post of December 7, 2007, Rick examines how the C# DataContext constructor handles default connection strings for Web sites and class libraries.

Added : 12/7/2007

Eric White: Four LINQ to XML Performance Posts

The XML Team's Eric White has assembled four performance-related posts:

Each post provides a narrative about the performance impact of the topic but doesn't compare actual execution times.

Miguel de Icaza: Moonlight 1.0 Due in Six Months, 1.1 to Follow Shortly

Mary Jo Foley reports in her First Moonlight port of Silverlight to Linux due in six months post of December 6, 2007 that Novell's VP of Developer Platform and lead Mono/Moonlight contributor, Miguel de Icaza, said at the XML 2007 conference in Boston that the Moonlight 1.0 port for Silverlight 1.0 on Linux will be fully cooked in 6 months.

Mary Jo also quoted Miguel as saying Moonlight 1.1, which includes Mono, "will be ready shortly thereafter and Moonlight 2.0 will follow Silverlight 2.0's RTM by about six months.

Added : 12/6/2007

Entity Framework Beta 3 Available for Download

What it says. The files are here:

The background and links to related posts are in the Entity Framework Beta 3 Available for Download.

Added : 12/6/2007

Brian Beckman Interviews Sam Drucker About the Entity Framework

Microsoft's "Renaissance Man" of mathematics, physics, set theory, etc., Brian Beckman, interviews Data Programmability General Manager Sam Drucker about object/relational modeling (O/RM) with inheritence and other hard-core Entity Framework (EF) issues in this 1:03 Channel9 video segment of December 5, 2007, Expert to Expert: Brian Beckman and Sam Druker - Deep Entity Framework.

Sam gives what I think is the clearest view of the value-add of the Entity Data Model in an environment where databases have an order-of-magnitude greater lifetime than their front-end applications. He also explains why the Astoria team used EF in their .NET Data Services.

Added : 12/6/200

Scott Guthrie Explains Passing ViewData in the ASP.NET MVC Framework

Scott's ASP.NET MVC Framework (Part 3): Passing ViewData from Controllers to Views of December 6, 2007 (at 2:49 AM) explains how to deliver a Northwind Category and its Products from a LINQ to SQL DataContext to a label bulleted list in a view using a ViewData dictionary (key and string value) or strongly-typed List<Product>.

Scott doesn't seem to require the traditional eight hours of sleep.

Added : 12/6/2007

Mike Taulty on Asynchronous LINQ to SQL Queries and the DataContext.Translate() Method

Mike's LINQ to SQL: Asynchronously Executing Queries post of December 6, 2007 outlines an approach to executing LINQ to SQL queries asynchronously with the DataContext.GetCommand() method and then with DataContext.BeginQuery(IQueryable) and DataContext.EndQuery(IQueryable) extension methods.

His same-day LINQ to SQL: DataContext.Translate and Anonymous Types post observes that the DataContext.Translate() method wants a concrete type as its argument and won't accept an anonymous type. (The VS 2008 docs say that the Translate() method converts an existing DbDataReader to objects. Each row in the DbDataReader is converted to an object in an IEnumerable<(Of <(T>)>) sequence.

Added : 12/6/2007

Zlatko Michailov Explains Entity SQL's Canonical Functions

Zlatko says Beta 2 introduced Entity SQL's canonical functions for which the Entity Framework defines the syntax but the .NET Data Framework API defines the behavior for a specific data provider. His Entity SQL: Canonical Functions post provides a brief description of the canonical functions.

The ADO.NET Entity Framework > Feature Reference > .NET Framework Data Provider for SQL Server path to the Canonical Functions list for SQL Server that that Zlatko's post provides doesn't exist for the Feature Reference topic that purports to be for Beta 3 or Beta 2's AdoNetEntityFramework.chm help file, which appear to be identical.  Maybe Zlatko has the real Beta 3 documentation.

  • Update: The online files were out of sync as of 12/6/2007 13:30 with the help files installed by the Beta 3 runtime. See my Entity Framework Beta 3 Available for Download for more details.

  • Added : 12/6/2007

    Rodney Lake Clones LINQ to SQL DataContext for Attach Operations

    New Zealand developer Rodney Lake's Clone Entity method for LINQ to SQL Datacontext post of December 6, 2007 includes the source code for a CloneEntity() method that creates by reflection a new instance of a DataContext with the same values as the original entity. You can attach the clone to a DataContext for update "without any problems" using this syntax:

    MyEntityType newUnattachedEntity = dataContext.CloneEntity <MyEntityType>(oldAttachedEntity);

    His post provides the C# source code for the method.

    Added : 12/6/2007

    First Volta CTP Available from Microsoft Live Labs

    The first public attempt by Erik Meijer to "Democratize the Cloud" is ready as of 11:00 AM PST, December 5, 2007, for VS 2008 developers to test-drive a Community Technical Preview. You can read the details about Volta, a product of the Tesla incubator group, and download the first CTP from Microsoft Live Labs' newly minted Volta site.

    Erik originally referred to Volta as "LINQ 2.0", which established its association wtih LINQ for these posts. The LINQ 2.0 prefix is no longer in use, but we'll continue to report on Volta's progress (partly because Erik Meijer is considered by most to be the "Creator of LINQ.")

    More details and a sample screen capture from the Volta samples are at First Volta CTP Available from Microsoft Live Labs.

    Added : 12/5/2007, Updated: 12/6/2007

    VB Hands On Labs for VS 2008 RTM Released

    You can download the Visual Basic LINQ Hands On Labs for Visual Studio 2008 package dated December 3, 2007 from the Download Center. (I don't recommend trying the Beta version of the proposed Silverlight "upgrade," if you're given the opportunity. The eye candy detracts from usability.)

    Here's the Overview:

    These Visual Basic LINQ Hands-on Labs provide an introduction to the LINQ Project. Learn basic LINQ features, including the Standard Query Operators, and see how these features can be used against in-memory collections, connected databases, and XML documents. The labs also provide a clear picture of the relational data access support provided by the LINQ Project, referred to as LINQ to SQL.

    Added: 12/5/2007

    Zlatko Michailov Digs into ObjectQuery<T>.ToTraceString() and .CommandText

    Zlatko's What Do ObjectQuery’s Builder Methods Build post of December 4 describes how removing the command tree from the process of constructing Entity SQL from a LINQ to Entities query in Beta 2 lost the ability to expose the Entity SQL's intermediary text and the final SQL statement. Beta 3 adds ToTraceString() method for Entity SQL and CommandText property for SQL to the ObjectQuery<T> object. His How to Get the Native SQL from an ObjectQuery and How to Get the Native SQL from an EntityCommand explain the process in excruciating detail.

    Using the ToTraceString() method was the topic of Alex James' ObjectQuery<T>.ToTraceString() and possibilities... post of December 4, 2007 (see Below).

    Added: 12/5/2007

    Faisal Mohamood Signs on as New ADO.NET Program Manager

    The ADO.NET Team announced in New ADO.NET Team Members - Part 2 of December 4, 2007 that Faisal Mohamood is a new program manager for LINQ to SQL and Entity Framework Object Services.

    Apparently, Faisal doesn't plan to start his own LINQ-related blog (yet). He has an ASP.NET Weblog with a last posting on December 14, 2004 and a SlashStar blog about his job as an MSBuild PM with four posts in 2005. He made several contributions to the MSBuild Team Blog in 2006, so you might watch for his posts in the ADO.NET Team blog.

    It's nice to see the ADO.NET team taking my suggestion about announcing new staff members.

    Added: 12/5/2007

    LINQ to XSD Redux and LINQ to Stored XML Coming

    It appears that the Data Programmability/XML Team is ready to continue Ralf Lämmel's efforts to make strongly typed LINQ to XML queries a reality by rejuvenating the LINQ to XSD project.

    Shyam Pather is presenting LINQ to XML: Visual Studio 2008, Silverlight, and Beyond session tomorrow at the XML 2007 conference in Boston.Shyam's abstract for the session discusses LINQ to XSD as one of the LINQ to XML Team's two incubator projects.

    The other incubator project is LINQ to Stored XML for querying SQL Server 2005+'s xml datatype.

    Read all about it here.

    Added: 12/4/2007

    Bill Horst Translates T-SQL to LINQ Queries: Part 3

    Converting SQL to LINQ, Part 3: DISTINCT, WHERE, ORDER BY and Operators (Bill Horst) continues the VB Team's weekly posts that compare T-SQL and corresponding LINQ query syntax.

    Added: 12/4/2007

    Alex James takes the Wraps off ObjectQuery<T>.ToTraceString()

    Alex's brief ObjectQuery<T>.ToTraceString() and possibilities... post of December 4, 2007 describes the forthcoming ToTraceString() method of the Entity Framework's ObjectQuery<T> object. ToTraceString() performs the same function as LINQ to SQL's DataContext.Log without having to resort to TextWriter and StringBuilder objects.

    Alex promises to demonstrate how you can perform bulk updates with LINQ to Entities in his next post.

    Added: 12/4/2007

    The ADO.NET Team's New ADO.NET Team Members - Part 3 post of December 5, 2007 finally confirmed Alex's new occupation.

    Updated: 12/5/2007

    Beth Massi Spots Northwind Customers with LINQ to XML and Virtual Earth

    Beth's Northwind Meets Virtual Earth - Generate VE Maps with LINQ post of December 3, 2007 describes a VB application that uses LINQ to XML and Locative Technology's service to geocode the addresses of Northwind's Oregon customers into <latitude> and <longitude> pairs of RSS <item> elements. JavaScript code then sends the RSS document to Virtual Earth and returns an .aspx page that contains a map with a pin at the location.

    You can download the source code here.

    Added: 12/4/2007

    Mike Taulty Posts LINQ to XML Annotations and Events

    Mike's Video - LINQ to XML Events and Annotations post and video clip of December 3, 2007 deals with two seldom-used LINQ to XML features:

    • The Annotations property of an XElement or XAttribute let you associate any object with a specific location in your document.
    • The Change event fires when any change occurs to the document; eventArgs return the type of change.

    The post include a set of links to Mikes prior LINQ to XML video clips.

    Added: 12/4/2007

    Pablo Castro Gives Astoria Schedule in Guy Smith-Ferrier Interview

    This 28-minute Podcast: Pablo Castro On Astoria consists of a question-and-answer session recorded at Tech*Ed Developer, Barcelona. At about 2:50, Pablo gave the following development schedule for .NET Data Services (formerly code-named Project Astoria):

    • December CTP: December 2007 (first CTP from the "real" codebase)
    • Beta 1: Early 2008
    • RTM: First half 2008 ("near the middle of the year")

    Other topics include:

    • Future integration of Astoria with the Visual Studio platform
    • Differences between Amazon and SQL Server's SQLXML
    • DBA FUD with URI-based dynamic queries
    • LINQ to Astoria client with a LINQ-to-URI converter
    • Concurrency with timestamp ETags
    • Transactions

    Guy's 12/3/2007 post includes a link to the slides from his Astoria presentations.

    Added: 12/4/2007

    LINQ to SQL Beta 2 to RTM Breaking Changes Summary

    Jim Wooley reports in his More on VS 2008 breaking changes post of December 3, 2007 that you can download the summary of Dinesh Kulkarni's LINQ to SQL Beta 2 to RTM Breaking Changes as a .docx file.

    Jim also notes that a Visual Basic and C# Breaking Changes from Visual Studio 2005 to Visual Studio 2008 white paper is available, too.

    Danny Simmons Diagrams the Entity Framework

    In his Concepts Part II: Relationships post of December 2, 2007, Entity Framework, Danny Simmons provides a detailed diagram showing the relationships between Customer, SalesPerson, Order, and OrderLines entities, Relationship Manager, EntityReference, EntityCollection, ObjectStateManager, and ObjectStateEntry for each Entity.

    Here are the topics Danny covers in his narrative:

    • ObjectStateManager: Value-view over the Object Graph
    • RelationshipManager: Late-bound Access to Relationships in the Object Graph
    • Stubs: Working with Relationships and Partial Graphs

    My background is engineering, so I appreciate diagrams that show how software works.

    Note: The post relates to Danny's earlier Creating an original value object from the separate values stored in the ObjectStateManager post of November 21, 2007.

    Mike Taulty Demonstrates Streaming XML Output from LINQ to XML

    Mike's Video - LINQ to XML and Streaming Out Large Documents post of December 3, 2007 demonstrates how to use the new XStreamingElement class. Unlike XElement, XStreamingElement defers the execution of a query until the result is required, which reduces memory requirements for large documents.

    The description of the video is "Short video on working with table valued parameters in LINQ to XML," but there's no evidence I can find of an SQL Server 2008 table-valued parameter in the clip.

    Mike's post includes a collection of links to his earlier LINQ to XML videos.

    Julie Lerman Posts PowerPoints of Her DevTeach and DevConnections Sessions

    Julie's DevTeach and DevConnections session PowerPoints uploaded of December 1, 2007 contains links to the following LINQ and Entity Framework-related presentations:

    • ADO.NET Entity Framework Overview
    • Real World Entity Framework (multi-tier issues and patterns)
    • ADO.NET 3.5 Data Access Guidance
    • Access RESTful DataServices in the Cloud (aka Astoria/ADO.NET DataServices)
    • Databinding in ASP.NET with LINQ

    (The Real World Entity Framework slides were 404 the last time I checked.)

    Luke Marshall Replaces DTC with a LINQ to SQL Transaction Resource Manager Class

    Luke provides the source code for the LinqTransaction.SharedDataContext class library in his Avoiding MSDTC with LINQ to SQL post of December 3, 2007. The purpose of the class is to share a single DataContext across multiple operations within a single transaction so as to avoid loading the Distributed Transaction Controller. 

    Off-Topic: Pat Helland Continues His Tech*Ed Travelogue

    Monday -- The Coliseum, the Forum, the Palatine Hill, and the Pantheon -- Wow!! of December 5, 2007 covers several Roman tourist hotspots.

    Added: 12/5/2007

    His Sunday -- Cold Outside but Loved the Museum... of December 2, 2007 covers the pair's Sunday (November 17) in Rome.