Monday, November 26, 2007

LINQ and Entity Framework Posts for 11/26/2007+

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

JD Conley: Compile Your LINQ to SQL Queries for Performance

Rico Mariani's Linq to SQL Compiled Queries are thread-safe post of November 29, 2007 led me to JD Conley's Linq to Sql Surprise Performance Hit article of November 28, 2007. JD develops Facebook apps with VS 2008, .NET 3.5, and LINQ, and intends to release an open-source asynchronous Facebook library.

JD ran into a serious performance problem in his Photo Feeds Facebook app, which uses LINQ to SQL, that was causing his page to load slowly. It turned out that three page loads caused 1,176,879 calls to SqlVisitor.Visit and pinned the CPU. Compiling the query decreased load time by a factor of five and the app now "barely registers on the CPU when the page loads."

Rico says compiled queries are thread-safe, which is reassuring.

Daniel Moth Demonstratrates and Explains the Parallel Exensions

Microsoft UK's Daniel Moth posted the following short video clips and introductions to Channel9 on November 29, 2007:

Intro to Parallel Extensions to the .NET Framework

In this 22:27 tour of the Parallel Extensions sample code, you will learn where to focus your energy when you explore the samples. Watch this video in order to see how Parallel Extensions to the .NET Framework fit in the large picture and what goal it aims to solve.

Parallel LINQ (PLINQ)

Achieving "Declarative Data Parallelism" with the Parallel Extensions is achieved through Parallel LINQ (PLINQ). This 18:50 video explains how to parallelise your LINQ queries, how it works under the covers and how to configure it for advanced scenarios

How to use the static Parallel class

The .NET incarnation of the solution to "imperative data parallelism" lives in the static Parallel class of the Parallel Extensions assembly. If that sentence confuses you a bit, watch the 20:15 video for the full explanation.

His Parallel Extensions videos Errata post of the same day corrects minor gaffes, such as the "PFX" code name, pipelining description, and return sum instruction. He includes the first reference I've seen to the Parallel Extensions Team Blog, which went into business on November 29, 2007.

Thanks to Mike Taulty for the heads-up. (Mike: If you're reading this, Ralf Rottman has the answer for running Entity Framework Beta 2 on VS 2008 RTM. He doesn't know if the tools work.)

Added: 11/29/2007 

Parallel Extensions Team Blog Starts with Updates to the MSDN Magazine Articles

The new Parallel Extensions Team Blog posted the following five articles on November 29, 2007:

The "Luke Hoban Gets the Most Complex LINQ Query Award (and PLINQ Compatibility)" topic of my LINQ and Entity Framework Posts for 10/2/2007+ post has more details on the two MSDN Magazine articles.

Added: 11/29/2007

Parallel Extensions to .NET Framework 3.5 December CTP Available

As promised in Soma Somasegar's blog, you can download the Microsoft Parallel Extensions to .NET Framework 3.5, December 2007 Community Technology Preview starting today. ParallelFX includes Parallel LINQ (PLINQ), which Soma describes as follows:

Declarative data parallelism in the form of a data parallel implementation of LINQ-to-Objects.  This allows you to run LINQ queries on multiple processors.

PLINQ samples include the ray-tracing project that I described in the "Luke Hoban Gets the Most Complex LINQ Query Award (and PLINQ Compatibility)" topic of my LINQ and Entity Framework Posts for 10/2/2007+ post, which also describes the Parallel FX program and task parallel library. However, there's no sign of the project described in the "Joe Cheng Solves the Wide Finder Problem with LINQ and PLINQ" topic of my LINQ and Entity Framework Posts for 10/5/2007+ post.

So far, I haven't been able to find MSDN's "Concurrent Programming Developer Center" that Soma mentions in his post.

Update: 11/30/2007: Charlie Calvert provided this link to the Parallel Computing Developer Center.

Thanks to Mary Jo Foley and Fabrice Marguerie for the heads-ups.

Added: 11/29/2007

Entity Framework Beta 3 and ADO.NET Data Services (Astoria) Preview Due Next Week

According to Scott Guthrie's .NET Web Product Roadmap (ASP.NET, Silverlight, IIS7) post of November 29, 2007, Entity Framework (EF) Beta 3, presumably EDM Designer CTP 2, and a VS 2008 RTM-compliant preview of ADO.NET Data Services (formerly Project Astoria) will debut next week in conjunction with the newly-named ASP.NET 3.5 Extensions Release. Scott says, in part:

  • ADO.NET Data Services: In parallel with the ASP.NET Extensions release we will also be releasing the ADO.NET Entity Framework.  This provides a new modeling framework that enables developers to define a conceptual model of a database schema that closely aligns to a real world view of the information.  We will also be shipping a new set of data services (codename "Astoria") that make it easy to expose REST based API endpoints from within your ASP.NET applications.

For more details and commentary about the ASP.NET 3.5 Extensions Release and the version number change of Silverlight 1.1 to 2.0, see today's ASP.NET .NET 3.5 Extensions Preview to Include Entity Framework Beta 3, ADO.NET Data Services post.

Update 1200 PST: "In parallel with" and "also be shipping" don't necessarily mean "with the other pieces next week." Microsoft representatives wouldn't confirm to me that Entity Framework (EF) Beta 3, EDM Designer CTP 2, and the ADO.NET Data Services will release next week.

Added: 11/29/2007

Keyvan Nayyeri Syndicates Feeds with LINQ to SQL and WCF

Keyvan's Create RSS and Atom Feeds with LINQ and WCF Syndication in .NET 3.5 post of November 29, 2007 shows you how to take advantage of Windows Communication Framework's Syndication library and LINQ to SQL to generate Atom 1.0 or RSS 2.0 feeds from a SQL Server data source.

Added: 11/29/2007 

Diego Vega: Another New Entity Framework PM and Stealth Blogger

The Entity Framework (EF) team is staffing up program management in advance of the Beta 3 drop. The latest addition is Diego Vega whose been on the job but under the radar since mid-October. Diego's program area is LINQ to Entities.

Diego's latest post, Entity SQL Non-Quirkiness of November 27, 2007, describes the unwanted (but not unexpected) result of omitting the VALUE modifier in an aggregate (MAX()) subquery of an Entity SQL SELECT statement.

His first EF-related post, Choosing an Entity Framework API of November 7, 2007 contrasts the Entity Services (relational-to-entity mapper) and Object Services (object-to-entity mapper) layers, both of which accept Entity SQL Queries. Only the ObjectServices layer and its ObjectQuery type support Entity SQL and LINQ to Entities queries.

Like the other recent PM hire, Alex James (see the "Alex James Joins the ADO.NET Team as Program Manager for Metadata" topic of Link and Entity Framework Posts for 11/19/2007+), the ADO.NET team didn't announce that Diego had signed on and was blogging about EF. Thanks to Julie Lerman (again) for the heads up.

Added: 11/29/2007

Download Guy Burstein's LINQ to SQL Presentation and Sample Code

Advantech Senior Consultant and Microsoft MVP Guy Burstein presented a session on LINQ to SQL at Microsoft Israel's Developer Academy 2 conference on November 27, 2007. If you'd like a quick but comprehensive introduction to LINQ to SQL click here to download his slide decks and C# demo code.

Added: 11/28/2007 

Stefan Cruysberghs Queries Outlook and OneNote with LINQ

Add LINQ to Outlook and LINQ to OneNote as two new third-party LINQ implementations. Stefan's .NET - Querying Outlook and OneNote with LINQ post (in English) provides the following elements:

  • Wrapper class for Outlook 2007
  • Wrapper class OneNote 2007
  • Querying Outlook with LINQ
  • Querying OneNote with LINQ
  • Execute queries on Office data with LINQPad (additional article)
  • Source code for classes and console demo application

The Wrapper class for OneNote is quite complex because OneNote uses XML as its data store.

Added: 11/29/2007

Julie Lerman and Beth Massi Present Sessions at DevTeach 2007 Vancouver

DevTeach is conducting it's first West Coast conference in Vancouver BC starting Monday 11/26/2007 through Friday 11/30/2007.

Julie Lerman is delivering Introduction to ADO.NET Entity Framework on Wednesday, and Real World Entity Framework and Databinding in ASP.NET with LINQ on Thursday.

Beth Massi demoed her Visual Basic Tip of the Day Browser app and built a VB 2008 add-in for part of Ken Levy's Tuesday keynote address. She also presented Strategies for Moving VB6 Apps to .NET on Tuesday.

Beth's post mortem of her scheduled presentation and a description of her impromptu "Conquering XML with LINQ in Visual Basic 9" session on Thursday is in her DevTeach Part Deux post of 11/29/2007.

Note: Most Western Canadians I know are Anglophones and Francophobic.

Added: 11/28/2007 Updated 11/29/2007

Converting SQL to LINQ, Part 2: FROM and SELECT

The VB Team's Bill Horts continues the series about SQL to LINQ query conversion, which he started with Converting SQL to LINQ, Part 1: The Basics.

Added: 11/28/2007

Scott Guthrie: Silverlight 1.1 Tools for VS 2008 RTM Available

According to Scott's Silverlight 1.1 Tools Alpha for Visual Studio 2008 Available for Download post of November 26, 2007, you can download the updated Microsoft Silverlight 1.1 Tools alpha for Visual Studio 2008 RTM from here and the quickstart tutorial for the tools here.

Scott says:

The next public preview of Silverlight will include a ton of new runtime features, as well as a significantly enhanced VS 2008 tooling support.  I'll be blogging more details about this shortly.

Hopefully, the promised LINQ to XML addition will be in the next public preview.

Added: 11/27/2007 

Scott Wisniewski Generates a US Map from TIGER Files, LINQ to XML, and WPF

In what's probably the most complex jobs of data binding attempted so far with LINQ to XML and WPF, the VB Team's Scott Wisniewski describes how to draw a US map in his Map LINQ: Create Dynamic Maps with Visual Basic 9.0 and WPF article for MSDN Magazine's December 2007 issue. The map includes color-coded population data for all counties in each conterminous US state. Moving the mouse over a state emphasizes its outline.

The following screen capture has been widened to more closely represent the aspect ratio of a conventional US map. Click the image to display a full-size capture.

The sample code (30 MB, expands to about 150 MB) is available for download here. After you unzip the files to their designated folders, move the PolygonData and PopulationData folders from the ...\WPFApplication1 folder to the ...\WPFApplication1\bin folder and set WPFApplication 1 as the Startup project.

The XML files (133 MB) take a while to load and process with LINQ to XML queries, so be patient after you press F5.

Dietel Adds Microsoft LINQ Resource Center

Dietel & Associates, Inc. have added a Microsoft LINQ Resource Center to the 13 existing resource centers on their site. The LINQ center offers links to resources in the following categories:

"LINQ to Visual Basic" is an implementation that's new to me.

Bart De Smet Releases LINQ to Active Directory (LINQ to AD)

LINQ to LDAP has received an upgrade to Visual Studio 2008 and a name change to LINQ to Active Directory (a.k.a. LINQ to AD) according to Bart De Smet's November 25, 2007 LINQ to Active Directory (formerly known as LINQ to LDAP) is here post.

The new version offers the following features:

  • Translates into LDAP filters according to RFC 2254.
  • Simple and approachable entity model with support of propagating updates back.
  • Supports mappings to both the System.DirectoryServices (.NET) and ActiveDs (COM) APIs.
  • Ships with a set of samples.

You can download the new code from CodePlex.

Julie Lerman Unravels Entity Framework Namespace Ambiguities

Update 11/27/2007: Julie updated her Entity SQL difference when using ObjectQuery vs EntityClient post to indicate that ObjectQuery and Entity Client handle container name in entity SQL the same way. See the comment to this post by Danny Simmons.

Julie's Entity SQL difference when using ObjectQuery vs EntityClient post explains that EntityClient requires you to include the Entity Data Model's container name in the FROM clause of your Entity SQL statement, as in:

SELECT c FROM NorthwindEntities.Customer AS c

But you don't include the namespace in ObjectServices queries, such as:

SELECT c FROM Customer AS c

Because you've already assigned the namespace to an ObjectContext variable with a statement, such as:

Dim Nwind [As NorthwindEntities] = New NorthwindEntities

ObjectServices queries throw a runtime exception if you prefix the entity with its namespace.

Off-Topic: Pat Helland Recounts his Tech*Ed 2007 Developers Presentations

If you haven't heard, Pat Helland (of Fiefdom and Emissaries fame) has returned to Microsoft after a few years' exile at and now writes a blog. (I covered for Fawcette Technical Publications his participation with Paul Flessner in the Autonomous Computing keynote for Tech*Ed 2002.)

To mark his renewed presence on the conference circuit, Pat has posted backgrounders, abstracts, and links to slides for his two technical sessions and the closing general session at Tech*Ed 2007 Developers Barcelona:

My Very Large Databases: Bricks, BitVault and BigTable post of April 6, 2006 has some additional background on the topics Pat covered at Barcelona.

As a bonus, Pat posted a lavishly illustrated, running account of a one-week Mediterranean cruise with his wife to celebrate their second anniversary:

The series is definitely worth a read, especially if you've never ridden a cruise ship.

Bill McCarthy Uncovers XAttribute Namespace Issue in LINQ to XML

Bill warns in his Don't "p" on your XAttributes post of November 26, 2007 not to assign pn (where n is an integer) as a namespace prefixe when programmatically adding attributes in LINQ to XML. You're likely to incur an exception caused by using the same namespace prefix twice.

Ken Tucker Creates an Excel Spreadsheet with the Open XML SDK and LINQ to XML

Ken's Using LINQ to XML to create an Excel spreadsheet post of November 25, 2007 contains the VB code to use the Microsoft SDK for Open XML Formats to create an Excel 2007 spreadsheet document, workbook, and string table, and then uses VB's literal XML feature to add cells from the Northwind database.

His post includes the complete code for the process that you can cut and paste into a sample project.


Daniel Simmons said...

As it turns out, there was some miscommunication which led to Julie's blog post about container-qualified entityset names. Please check out the update she posted this afternoon at this page. Object Services and EntityClient actually handle this aspect of eSQL queries the same way.

--rj said...


The post has been struck out.