Showing posts with label Orcas March 2007 CTP. Show all posts
Showing posts with label Orcas March 2007 CTP. Show all posts

Thursday, April 26, 2007

More Issues with VB 9.0 Samples in the Updated LINQ to SQL Documentation

It's evident that no one tech-edited or double-checked the VB 9.0 code examples in the "LINQ to SQL: .NET Language-Integrated Query for Relational Data" whitepaper Dinesh Kulkarni, Luca Bolognese, Matt Warren, Anders Hejlsberg, Kit George that was updated in March 2007.

I encountered the most egregious example of the authors' disdain for VB in the following code snippet from the "Stored Procedures Invocation" topic:

<StoredProcedure(Name:= "VariableResultShapes")> _
  <ResultType(typeof(Customer))> _
  <ResultType(typeof(Order))> _
public VariableResultShapes(shape As Integer?) As IMultipleResults
  Dim result As IExecuteResult = ExecuteMethodCallWithMultipleResults(Me, _
    CType(MethodInfo.GetCurrentMethod(), MethodInfo), shape)
    return CType(result.ReturnValue, IMultipleResults)
End Function
The example uses C#'s typeof() instead of VB's GetType() function in lines 2 and 3, is missing the Function keyword on line 4, and uses the unsupported ? symbol for Nullable(Of T) on line 4. There are obvious errors on 50% of the lines of the example. Further, the following required Imports statements are not to found anywhere in the document:
Imports System.Data.Linq
Imports System.Data.Linq.Provider
Imports System.Reflection
It would behoove authors of whitepapers with a penchant for C# to at least check to see if their VB sample code compiles.

By the way, Kit George is a program manager on the VB team and presented the LINQ Overview Webcast on April 25, 2007.

Updated 4/27/2007: Dropped initial (off-topic) paragraphs.

Thursday, April 05, 2007

Danny Simmons Featured on .NET Rocks

Carl Franklin's and Richard Campbell's .NET Rocks interview with Danny Simmons for Show #226, "Daniel Simmons on ADO.NET Entity Framework" appeared today. The show runs 1:08:00 and the interview with Danny starts at 0:08:20.

Update: 5/16/2007: The transcript for this segment is here. Danny's interview starts at the bottom of page 3.

Danny says at the start of his interview that he's been at the center of the Entity Framework's Object Services layer from its beginning.

Persistence Ignorance Missing in the Entity Framework

Here's an early excerpt that relates to Danny's participation in the "Persistence Ignorance" flare-up during the recent MVP Summit at Redmond:

11:45 Richard Campbell mentioned the "O/RM Smackdown" and that he sat at the back of the Entity Framework session at the recent MVP Summit in Redmond. He described "usual suspects," who were in the center of the room on the right, as the "NHibernate Mafia" (James Kovacs, Scott Bellware, Jeffrey Palermo, Jean-Paul Boodhoo, all NHIbernate believers) in a little cluster hammering Microsoft's ADO.NET folks. Danny was sitting at the left in the front, and popped up a couple of times to answer questions. When the session broke, it took him an hour to get out of the room.

14:30 Danny Simmons: Next day we scheduled a lunch [with the NHibernate Mafia] and just went at it. These folks have the impression that we just don't get their style of working. We don't get what they do within NHibernate and are trying to build "this other product." We gave Jeffrey Palermo our vision for a few releases out, this is what it could be like. Jeffrey said, "Yeah! Perfect! You've got it!" I said, "Now let me tell you why it's not coming out that way in this release."

Comment: I would have enjoyed hearing the "vision" and "why it's not coming out" in the Orcas release.

Jimmy Nilsson and the Disappearing Entity Framework Docs

15:50 Carl Franklin: Jimmy Nilsson blogged about the Entity Framework and all traces of the Microsoft documentation for it suddenly disappeared from the Internet. People kid Jimmy that he "killed the product."

Comment: Go to Jimmy's blog and search for the "Infrastructure and EDM" item of 5/12/2006 and its update to find the alleged culprit. (As far as I can determine, Jimmy's attributes the term "Persistence Ignorance" to Martin Fowler, but I haven't found any evidence of Fowler's use of the term or that Fowler has added it to his Catalog of Patterns of Enterprise Application Architecture or Development of Further Patterns of Enterprise Application Architecture page.)

For more details on the missing EF and EDM documents see my 3/15/2006 ADO.NET 3.0 Entity Framework Ephemera and, for their restoration, ADO.NET 3.0 Entity Framework Docs Redux of 6/19/2006.

Defining the Entity Framework and Distinguishing It from an O/RM Tool

The ADO.NET team avoids categorizing the Entity Framework as an Object/Relational Mapping tool, such as NHibernate and commercial O/RM products, although the Object Services layer maps entities to partial CLR classes and relationships. Danny defines the Entity Framework:

16:45 The idea of the Entity Framework is to create a new data model that's a higher abstraction than the relational model. The goal is to give the business model the same theoretical underpinnings--to give it the long-term legs--of the relational model. It's based on Peter Chen's Entity-Relationship model.

17:50 The Entity Framework makes a real runtime representation of the structure--the model of your data, and the constraints on that, in terms that are much closer to the way your application runs.

18:20 In general, it falls into the O/RM model. But there's a key distinction. We're trying to capture the structure and the relationships and constraints on the data as a separate thing before you get to the point of designing your business objects that have behaviors.

Comment: Don't miss Channel9's Dr. Peter Chen: Entity Relationship Model - Past, Present and Future segment video segment, in which Peter Chen and ADO.NET architect Jose Blakeley participate.

EDM Designer[s] and Their Delivery

The EDM Designer won't be in the Orcas RTM, but Danny says:

26:10 We will ship out of band on the Web more visual tools [for] designing the schemas, and maybe even getting to the point of visually specifying the mapping. Today you have to do that in a declarative format and long term I believe we're going to need a whole variety of [designers].

Comment: It's doubtful if many developers will adopt Orcas's Entity Framework for production apps until an "out of band" drop of the forthcoming EDM Designer proves it can handle modifications to XML schema files that cover 95% or more of developers' requirements.

LINQ to Entities vs. Entity SQL

It's still not clear to most developers when to use LINQ to SQL, the EDM with LINQ to Entities, or the EDM with Entity SQL (eSQL). Danny says the following about EDM with LINQ to Entities or eSQL:

29:30 It's a key concept in LINQ [to Entities] to define an interface to IQueryable and get a handle on that specification instead of the compiler actually compiling it. We do a runtime translation of that query specified into the same query trees and then it runs through all the rest of our stack the same as if you had specified the query any other way.

30:00 EntitySQL is very close to SQL, but it has extensions that understand inheritance and navigating relationships. It is a full-representation query language, so you can compose your queries, you can do joins, you can do very, very rich queries.

30:30 You can either buy into LINQ, which for some solutions makes very great sense, or use the text-based [eSQL] query option.

Comment: Danny didn't compare the Entity Framework and LINQ to SQL. LINQ to SQL connects SQL Server (only) databases directly to table-based objects with no intervening mapping layer. LINQ to SQL supports limited limited inheritance; the rows for base class and subclasses must be contained in a single database table. Unlike the Entity Framework, you can generate an SQL Server database from an entity model you create from scratch. Julie Lerman's LINQ to SQL vs. Entity Framework post provides more detailed distinctions, and check out Kevin Hoffman's early (August 2006) LINQ to Entities vs. LINQ to SQL - What should I use and when? post, which contains a feature-by-feature comparison.

Code Generation in Orcas and Future Versions

The present Entity Framework implementation, including the EDM Wizard, starts with the database schema and works up to the EDM and its Object Services.

43:10 The kind of generation we have now goes up from the database to the model. But a lot of people want to go from the object down and generate the database. If I add a property to an object, I want a script generated to add the field to the table and another script to remove it if I change my mind.

44:45 An interesting designer story is "I'm not trying to generate my code from my model, but I'm writing my code and putting hints in it, so we can generate the model out of the code."

45:25 In Orcas, we're getting some of this direction. Like many of the Visual Studio Designers, "Hey, there's this way you can design the model and then we'll do code generation of partial classes." But you also have the option of writing your classes from scratch, implementing a few interfaces that allow us to be aware of what's going on, and then writing the model by hand.

In a later release, we want to go to the next step, which is to write your classes and you tell us to build the model for you. Either one time or in an incremental fashion because "the truth is in the classes." But we have some customers who say "the truth is in the model," so we want to support them, too.

48:00 If you take the Entity Framework vision farther and farther forward, you eventually say, "Well, why do I need to specify the relational model at all? Why don't I hand my entity model directly to SQL [Server] and say 'Store this and do it fast!'"

Comment: The Orcas March 2007 CTP's EDM Wizard does a reasonable job of generating the XML mapping files and class code from the database up but, unlike LINQ to SQL, won't generate a database (or write CREATE DATABASE/TABLE or ALTER TABLE scripts) from the model.

Entity Framework in Orcas March 2007 CTP and Beta 1

50:40 From the standpoint of the Entity Framework, the March CTP and Beta 1 are almost identical. There's some last bit of features that we're busily working on now that will appear in Beta 2 and the Orcas Release. Search Technorati for "Entity Framework" and you'll find some interesting blog entries.

Comment: Be sure to use the double-quotes when you search for "Entity Framework" or you'll receive 4,000+ hits (90% off-topic) instead of 400+ that I found today.

Update 4/6/2007: Major restructuring and additions. 4/7/2007: Added links, made minor corrections, and fixed typos.

Tuesday, March 27, 2007

Third-Party LINQ Providers

Following is a short list of the third-party LINQ providers I've found to date in more-or-less chronological order:

  • LINQ to WebQueries by Hartmut Maennel handles searches in the SiteSeer and MSDN Web sites. (This provider predates Fabrice's LINQ to Amazon provider by a few days.)
  • LINQ to Amazon by Fabrice Marguerie, a co-author of the forthcoming LINQ in Action book, was the first third-party LINQ provider that I know of. LINQ to Amazon returns lists of books meeting specific criteria.
  • LINQ to RDF Files by Hartmut Maennel handles queries against Resource Description Format files' triples. Part I of the two-part post is here.
  • LINQ to MySQL by George Moudry, based on the LINQ May 2006 CTP, was in the development stage as of January 2007, but George says it's "capable of simplest queries and updates" and "now has support for most primitive joins."
  • LINQ to NHibernate by Ayende Rahien (a.k.a. Oren Eini) translates LINQ queries to NHibernate Criteria Queries and is based on the Orcas March 2007 CTP. The documentation that describes development of the provider presently is at the Part 1 stage.
  • LINQ to LDAP by Bart de Smet is a "query provider for LINQ that's capable of talking to Active Directory (and other LDAP data sources potentially) over LDAP." As of 4/11/2007, Bart's "IQueryable Tales - LINQ to LDAP" consisted of Part 0: Introduction, Part 1: Key Concepts, Part 2: Getting Started with IQueryable, Part 3: Why do we need entities?, Part 4: Parsing and executing queries, and Part 5: Supporting Updates.
  • LINQ to Flickr by Mohammed Hossam El-Din (Bashmohandes) uses the open-source FlickrNet C# library as its infrastructure.
  • LINQ to Google Desktop by Costa Rican programming language enthusiast Luis Diego Fallas supports GDFileResult and GDEmail types. A subsequent Adding support for projections to Linq to Google Desktop implements the LINQ Select expression.
  • LINQ to SharePoint by Bart de Smet supports writing LINQ queries for SharePoint lists in both C# 3.0 and Visual Basic 9.0 and communicates with SharePoint via Web services or though the SharePoint Object Model. The SpMetal command-line utility automates C# or VB class generation.
  • LINQ to Streams (SLinq, Streaming LINQ) by Oren Novotny processes continuous data streams, such as stock tickers or sensor data. The project's home page on CodePlex includes an animated GIF simulation of a stock ticker displayed in a DataGridView. The current version supports Select, Where, Order By, and Descending only.
  • LINQ to Expressions (MetaLinq) by Aaron Erickson (the developer of Indexes for Objects a.k.a i4o*) lets you query over and edit expression trees with LINQ. Like .NET strings, LINQ expression trees are immutable; the only way you can change a LINQ expression tree is to make a copy, modify the copy, and then replace the original. MetaLinq's ExpressionBuilder lets you create an "Editable Shadow of an expression tree, modify it in place, and then by calling ToExpression on the shadow tree, generate a new, normal, immutable tree." ExpressionBuilder is an analog of the .NET StringBuilder.

* i4o isn't a LINQ provider, per se, but a helper class that can increase the speed of LINQ queries against large collections by a factor of 1,000 or more. InfoQ published on June 22, 2007, Aaron Erickson on LINQ and i4o, an interview of Aaron Erickson by Jonathan Allen about i4o's purpose and background.

Ayende observes:

There is an appalling lack of documentation about how to implement LINQ providers. ... I decided to document what I found out while building LINQ for NHibernate.

However, the "appalling lack of documentation" hasn't thwarted the work of third-party LINQ providers for specialty data domains. A search of the CodePlex site on LINQ returned 15 projects as of 6/3/2007.

If you know of other third-party LINQ providers in development, please leave a comment.

Thanks in advance.

Update 3/29/2007: .NET Rocks features "Oren Eini On NHibernate and RhinoMocks!" as its 3/29/2007 broadcast. LINQ to NHibernate might become a much more popular LINQ provider if the ADO.NET Team doesn't finish the EDM Designer by Orcas RTM. The interview with Oren starts at 11:00. (Thanks to Danny Simmons for the heads-up.) .NET Rocks TV (dnrTV) taped an instructional video interview with Oren on January 25, 2007.

Update 4/7/2007: Added Bart de Smet's LINQ to LDAP project, which includes extensive IL code inspection of LINQ queries.

Bobby Diaz has extended Ayende's initial Part 1 From ... In ... Where ... Select implementation with Part 2: Ordering and Paging (adds Order By, Then By, OrderByDescending, ThenByDescending, Take, Skip, and Distinct) and Part 3: Aggregate and Element Operators (adds First, FirstOrDefault, Single, SingleOrDefault, Average, Count, LongCount, Max, Min, and Sum.) The momentum is building behind LINQ to NHibernate.

Update 4/11/2007: Added Mohammed Hossam El-Din's LINQ to Flickr provider and updated LINQ to LDAP with parts 4 and 5.

Update 5/6/2007: Added Bart de Smet's LINQ to SharePoint project, version 0.1.2.0 Alpha release.

Update 5/12/2007: Added Helmut Maennel's early LINQ to WebSearch and LINQ to RDF Files providers. I haven't tested these providers with later LINQ implementations.

Update 6/3/2007: Added Oren Novotny's LINQ to Streams (SLinq) and Aaron Erickson's LINQ to Expressions (MetaLinq) and Indexes for Objects (i4o).

Update 6/11/2007: Added Luis Diego Fallas' LINQ to Google Desktop of May 11 and 12, 2007, which I had missed.

Update 7/22/2007: Added link to inteview with Aaron Erickson about i4o.

Update 8/7/2007: Aaaron Erickson has written "Indexed LINQ" for .NET Developer's Journal. Subtitiled "Optimizing the performance of LINQ queries using in-memory indexes," the article covers the theory behind creating indexes on in-memory collections and applying an extension method to the Where() standard query operator to enable speeding queries by up to a factor of 100 or so with the indexes. You can download the source code, runtime binary or both for i4o at http://www.codeplex.com/i4o.

Monday, March 26, 2007

Updated "Overview of Visual Basic 9.0" Stealth Post

Microsoft recently published a February 2007 update to "Overview of Visual Basic 9.0" by Erik Meijer, Amanda Silver and Paul Vick as a Visual Studio 2005 Technical Article. The update's timing obviously is tied to the Orcas March 2007 CTP release, which occurred in late February. The first reference I've seen to it was by Beth Massi (a.k.a, DotnetFox) on February 9, 2007 in the Hooked on LINQ wiki, although it's possible that the reference could be to an earlier version.

I use the term stealth post because none of the authors or the Visual Basic Team has mentioned the updated version publicly, as far as I can determine. Following are the results of searches I ran to find references to the February 2007 version:

Note: Jim and I discovered the February 2007 version from the link in Bill McCarthy's blog of yesterday.

Updated documentation for the language extensions to Visual Basic 9.0 is important, at least to VB programmers, although the Orcas March 2007 CTP include VB-specific topics for anonymous types, object identifiers, and query expressions, as well as a substantial number of LINQ-related online help topics.

The lack of links to the Overview's February 2007 version is surprising, considering that one of its authors, Paul Vick, is an active blogger and Amanda Silver posts to the Visual Basic Team blog occasionally. Could the reason for the lack of links be that the authors aren't proud of their work?

Issues with the February 2007 Version

Jim Wooley takes issue with some of the content of the February 2007 update in today's VB 9.0 documentation post:

I took a couple minutes looking it over and it does give a quick glimpse of the basic underlying concepts that hopefully are coming. Unfortunately, there are a number of items in the documentation that don't appear to be included in the current [Orcas March 2007] CTP. I am definitely hoping that they do make it in the next drop. The features that are discussed but not yet included are: Joins, Lambdas, and [shorthand DateTime? syntax for] Nullable types. In addition, the samples seem to use an Auto-Implemented Property syntax as introduced in the current C#, but reading more closely, they are just using a pseudo code syntax. [Emphasis added].

Jim then adds details about the three missing features.

Comparison with and of Previous Versions

The February 2007 version contains the following topic list:

  • Introduction
  • Getting Started With Visual Basic 9.0
  • Implicitly Typed Local Variables
  • Object and Array Initializers
  • Anonymous Types
  • Deep XML Support
  • Query Comprehensions
  • Extension Methods and Lambda Expressions
  • Nullable Types
  • Relaxed Delegates
  • Conclusion

The previous version was first published as a Microsoft Word file by the same authors in September 2005. The LINQ May 2006 CTP contained an updated May 2006 version of of the September 2005 release. The topic lists were the same for both versions:

  • [Getting Started with VB 9.0]
  • Implicitly typed local variables
  • Query comprehensions
  • Object initializers
  • Anonymous types
  • Full integration with the Linq [sic] framework
  • Deep XML support
  • Relaxed delegates
  • Nullable types
  • Dynamic interfaces
  • Dynamic identifiers
  • [Conclusion]

The primary differences between the two previous versions, determined by running a compare operation between the two .doc files with Microsoft Word, were minor syntax changes and adoption of the C# syntax/sequence (From ... Select) for LINQ queries. There were 127 deletions and 117 insertions, most of which were one or a few characters.

Jim Wooley's Converting from VB LINQ to Orcas post documents the manual changes required to make his LINQ May 2006 samples run with the Orcas March 2007 CTP LINQ implementation.

Update 3/28/2007: Beth Massi, who's taken a new job at Microsoft "writing content for the Visual Basic Developer Center and promoting the Visual Basic language in the community," notes in a comment that the What’s New in Visual Basic 9.0? link on the main Visual Basic Developer Center page links to the updated post. However, it's my recollection that this link formerly pointed to earlier version(s) and there's no indication that the information was recently updated. Beth says there will be pointer to the doc in a future VB Team post.

Friday, March 23, 2007

A Sync Services Bidirectional Test Harness

The Microsoft Synchronization Services (Sync Services) 1.0 API (runtime) requires a substantial amount of developer-authored code to define the basic elements required to perform bidirectional synchronization between an SQL Sever 2005 Compact Edition (SSCE) client and an SQL Server 2005 [Express] or other RDBMS server. The VB code (without empty lines or comments) to implement bidirectional synchronization for a pair of simple tables is about 95 lines if you take advantage of the runtime's CommandBuilder or about 165 lines if you don't.

Beta 1 Update May 15, 2007: The test harness was built and tested with the Orcas March 2007 CTP. Upgrading the project to Beta 1 exposed some new Sync Designer and SSCE v3.5 problems that prevent its operation. There is no effective workaround available at this time. (See my Sync Designer/SSCE Version Problems with Orcas Beta 1 post in The Microsoft Synchronization Services for ADO.NET forum.) The Sync Services team says that the Sync Designer problems are "fixed in a later build" and "most changes to runtime and designer are coming in beta 2.0." The SSCE team hasn't replied regarding fixes for compatibility problems with SQL Server Management Studio and Server Explorer, which another forum participant has experienced. I'll update this post when an upgraded test harness becomes available for download from the Visual Studio Magazine site.

Background

The Sync Services Designer that debuts in the Orcas March 2007 CTP greatly reduces the effort required to get a simple unidirectional service up and running. Completing a couple of simple forms generates a DatabaseName.sync XML document and VB or C# class file with all but two lines of code required to produce a simple one-way, download-only synchronization project. The price you pay for automating the service design process is the requirement to use SQL Server 2005 [Express] (or SQL Server/MSDE 2000) as the server RDBMS. The Sync Services 1.0 runtime is server-agnostic, as demonstrated by Rafik Robeal's use of Oracle 10g Express in his Demo V: Offline Application - Oracle Backend C# project.

All of Rafik's Sync Services runtime demos use simple orders and order_details tables with random primary key values. The orders table has order_id and order_date columns and order_details has order_id, order_details_id, product (name), and quantity columns. Both tables use order_id (int) as the sole primary key column, which has as PK_orders or PK_order_details (PK, Unique, Non-clustered), and UQ__orders__##### or UQ__order_details__##### (Unique, Non-clustered) indexes. This selection of keys prevents establishing a one-to-many relationship between orders and order_details tables, so there are no foreign key fields.

Update: 3/24/2007: Rafik added a Deep in Sync: Handling PK-FK Constraints post to The Synchronizer blog yesterday. This post explains Rafik's reason for not including PK/FK relationships and details the workings of—and settings for—these relationships in detail. Sync Services interprets the first table in the addition of client-side SyncTables and server-side SyncAdapters to their respective collections as the parent table. Adding related SyncTables to the SyncGroup that's attached to the SyncAgent assures that Sync Services processes the table changes as a unit.

A Sync Services Bidirectional Test Harness (Work in Progress)

Here's a preview of my Sync Services test harness, which (as usual) uses the Northwind Orders and Order_Details tables to emulate pseudo "real world" order and line items data. There's a one-to-many relationship (FK_Order_Details_Orders) between the identity primary key (OrderID) on the Orders table and composite primary key (OrderID, ProductID) on the Order_Details tables of both the client and server database. One of the purposes of the test harness is to determine whether it's practical to use Sync Services to replace merge replication for master/child tables. (This question remains unanswered at present, but the ability to replace RemoteDataAccess (RDA) seems assured).

The test harness project is in development at present; the downloadable sample code will accompany an article for Visual Studio Magazine's May 2007 issue. Click the images to display a full-size version.

Figure 1 - SQL Server 2005 Compact Edition Client Cache Page

The Client above and Server (below) pages enable selecting automated UPDATE, INSERT, or DELETE operations and provide rapid comparison of the latest additions to the client and server tables. You type the number of Orders and Order Details records in the text boxes and then click the Random Insert/Update/Delete button to apply the changes to the SSCE tables. Updates randomly alter the EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, and Freight field values of the Orders table and ProductID, Quantity, Unit Price, and Discount of the Order_Details table. Inserts add a random selection of a CustomerID value from the Customers table.

Clicking Synchronize starts the synchronization process. You can select from three methods of handling synchronization data conflicts on the client page.

Clicking the Add FK Constraints button adds a DataRelation between the Orders and Order_Details tables to the database and the NorthwindDataSet. (By design Sync Services doesn't add DataRelation(s) during the database and table creation process, and a problem with the DataSet Designer prevents persisting changes.) Code adds or updates the LastEditDate value to the Orders table (not shown) and the Order_Details table.

Figure 2 - SQL Server 2005 Express Server Data Source Page

Figure 3 - Client Schemas and Sync Statistics Page

The schemas and statistics page has a DataGridView control to display SSCE INFORMATION_SCHEMA "views" (actually tables). The Client ID combo box and Set button are for testing behavior of SSCE's identity feature. Text boxes display sync statistics and CommandText property values for all operations. You can copy the commands to Notepad for better visibility.

Figure 4 - Sync Payload Page

The Payload page shows the data transferred between the server and client (and vice-versa).

Figure 5 - Test Grids Page

Test grids hold snapshots of data transferred in a more readable format than the Payload page's.

Updated 3/24/2007: Added link to Rafik PK/FK posts, plus minor additions and clarifications.

Thursday, March 22, 2007

SSCE Sync Designer Q&A and Screencast

Sync Services pilgrims working with the Sync Designer preview in the Orcas March 2007 CTP had many of their questions answered by Steve Lasker's Additional Q&A on the Visual Studio Orcas Sync Designer post of March 21, 2007, which supplements Steve's original Q&A on OCS & Sync Services for ADO.NET post of March 18, 2007. First look at the Visual Studio Orcas Sync Designer and Going N Tier w/WCF, Synchronizing data using Sync Services for ADO.NET and SQL Server Compact Edition are a pair of screencast posts (dated March 22 and 23, 2007), which cover the Sync Designer that's scheduled to debut in Visual Studio Orcas. SSCE Sync Designer Q&A

Steve answers these questions to which I've added some related references:

  • Why does the Orcas Feb CTP Typed DataSet designer not work on Vista? I discovered this problem at the end of the aborted guided tour described in my Guided Tour of Orcas's Sync Services Designer for SSCE post of March 17, 2007.
  • Will the Sync Designer generate time based sync? I mentioned the lack of this feature in the same post.
  • Will tombstone records be automatically cleaned up? Rafik Robeal covers this topic in his Sync Services: Periodic Tombstone Cleanup post of February 16, 2006 to The Synchronizer blog.
  • How do I get my cached tables to be synchronized in a single transaction? Rafik's A nice gift from SQL Server 2005 SP2 to sync developers post discusses an SQL Server 2005 fix for potential timestamp errors with uncommitted transactions.
  • Once all the tables are placed in a single transaction, how do I control the order the tables are updated to handle parent/child relationships? Rafik discussed this issue in a "Synchronizing an 'Order'" thread in the Microsoft Synchronization Services for ADO.NET forum.
  • Does the sync runtime create relationships locally within SQLce? I mentioned this problem in conjunction with the problem of inability to save design changes to SSCE DataSets in the Guided Tour of Orcas's Sync Services Designer for SSCE post.
  • Does the sync runtime work with server side identities for PK's? The test harness I'm building has OrderID identity columns on the client and server sides and currently uses identity partitioning (similar to merge replication's approach) to identify the client machine that's the source of the update. Ultimately, the test harness will use ROWGUIDCOL columns.

SSCE Sync Designer Screencast—Part 1: First look at the Visual Studio Orcas Sync Designer

Steve's first Sync Designer (a.k.a. Cache Designer) screencast (25:49) demonstrates two-tier, one-way (download-only) synchronization of updates to reference data (Customers, Employees, and Shippers) for the Northwind Orders table. Reference (also called catalog) data, such as customer, vendor, or product lists, ordinarily are quite large but usually change relatively slowly. Two-tier, one-way sync for changes only is likely to be the most common Occasionally Connected System (OCS) scenario.

These are the only two lines of code in the Synchronize button's event handler that you need to sync the client with the server tables using the defaults you set in the designer:

Dim SyncAgent As NorthwindCacheSyncAgent = New NorthwindCacheSyncAgent

Dim SyncStats As Microsoft.Synchronization.Data.SyncStatistics = _ SyncAgent.Synchronize

The test harness's Synchronize button's event handler has about 100 lines of code to specify sync type and conflict handling, add and remove event handlers, and display SyncStatistics.

SSCE Sync Designer Screencast—Part 2: Going N Tier w/WCF, Synchronizing data using Sync Services for ADO.NET and SQL Server Compact Edition

The second screencast covers the n-tier scenario with a Windows Communications Foundation (WCF) service as an intermediary between the client and server. The architecture is similar to that Rafik Robeal demonstrated in his Demo III: Offline Application – WebService project.

Update 3/23/2007: My Sync Services demo project (a work in progress) has been moved to this new location: A Sync Services Bidirectional Test Harness. Added link to Part 2 of the screencast. Incorporated reference to original Sync Services Q&A in first paragraph.

Monday, March 19, 2007

Mike Taulty Dissects LINQ to SQL

Thanks to Julie Lerman's Deconstructing LINQ to SQL post, I learned about Mike Taulty's two-part series that digs into the inner workings of the LINQ to SQL API:

Deconstructing LINQ to SQL (Part 1) discusses the differences and similarities between IEnumerable<T> and IQueryable<T>. Mike's abbreviated take is:

To me, the primary difference between IQueryable and IEnumerable with respect to LINQ is that I view IQueryable as offering the potential for "capturing the whole query and executing it in one go" whereas I view IEnumerable as "executing a set of functions in sequence on lists in order to produce more lists".

Deconstructing LINQ to SQL (Part 2) discusses how IEnumerable<T> and IQueryable<T> relate to LINQ to SQL. Here's Mike's conclusion:

I do now know where the T-SQL comes from and I do know that the infrastructure uses SqlCommand and so on but I still wouldn't like to say that I have this "nailed" because I think it's pretty hard to walk through without actually single-stepping the live source code and I don't have that (and, at some point, it's sensible to give up and accept that "it works.")

As I mentioned in this earlier Yet Another Primer on New Language Features in Orcas post, Mike is a Microsoft UK evangelist "involved in getting information out to developers about what's happening with the Microsoft platform through online mechanisms like newsletters, blogs, videos and through offline mechanisms such as technical sessions."

Sync Services for ADO.NET Overview

Steve Lasker's lengthy Q&A on OCS & Sync Services for ADO.NET post covers use of merge replication, Remote Data Access (RDA) and Sync Services for ADO.NET for synchronizing data between servers and clients (or publishers and subscribers) of Occasionally Connected Systems. As you'd expect, the emphasis is on Sync Services for ADO.NET with SQL Server Compact Edition (SSCE) v3.5.

Surprisingly, there's only one brief reference to the Sync Designer (in the answer to "Does Sync Services Support N Tier?") With the Sync Designer debuting in Orcas, I've been expecting more Q&A on the Sync Designer in the Microsoft Synchronization Services for ADO.NET forum. So far, searching on "designer" returns only two hits (one on 1/24/2007 and another 2/28/2007).

Maybe the lack of traffic is due to the strange name of the Orcas designer template: Local Database Cache (see Guided Tour of Orcas's Sync Services Designer for SSCE.) Data[base] Synchronization Service makes more sense to me. As of today, Google returned relevent hits on "Local Database Cache" only for Nick Randolph's and my posts. Same for "Sync Services Designer."

Update 3/21/2007: I should have searched for "local data cache" orcas, to pick up the Visual Basic Team blog's New Data Tools Features in Visual Studio Orcas post by Young Joo (3/13/2007). The post includes a "Local Data Cache with SQL Compact Edition" topic. The author omitted "base" and called the template "Local Data Cache." The article also:

  • Describes Hierarchical Updates with the new TableAdapterManager class, which simplifies code for executing updates on all of your DataSet's table adapters with the TableAdapterManager.UpdateAll(DataSet) method
  • Previews the newly-renamed Object Relational Designer (formerly the DLinq Designer)
  • Introduces n-tier support for typed DataSets by splitting the class file into another project.

Local Database Cache also suffers from lack of any documentation whatsoever. Try searching online help for "Local Database Cache" -- nada. (Hierarchical Update's help topics appear complete and Object Relational Designer has an unfinished walkthrough.)

Get The Bits

Here are OakLeaf links to details for downloading the current SSCE CTPs, RTMs and samples:

Saturday, March 17, 2007

Guided Tour of Orcas's Sync Services Designer for SSCE

Nick Randolph, co-author of WROX's Professional Visual Studio 2005 and Microsoft Visual Developer/Device Application Development MVP , has published a two-part demonstration for using the Orcas March 2007 CTP's new Sync Designer that starts when you add a Local Database Cache (LocalDataCache1.sync) template to your project.

Part 1 stops at the Add New Item dialog that displays Local Database Cache and Service-based Database templates.

Part 2 continues with the Configure Data Synchronization and Configure Tables for Offline Use dialogs.

Note: For assistance with Sync Services and Sync Designer issues, I recommend the Microsoft Synchronization Services for ADO.NET forum. The Synchronizer blog and Rafik Robeal's SyncGuru site offer downloadable C# Sync Services sample projects, documentation, and commentary. Nick Randolph's SQL Server CE Portal site offers FAQs for SSCE and Sync Services, including a sample VB project that improves on Rafik Robeal's C# code for configuring Sync Services.

My Problems with the Sync Designer

The series is similar to a demonstration page that I put together last week for the Orders and Order_Details tables of the Northwind sample database. I didn't publish it to the blog because the Wizard failed at the last step.

As noted in steps 9 through 11 of my test drive:

9. Under Windows Vista running on Virtual Server 2003 R2 Beta 1, the Orcas Data Source Configuration Wizard creates NorthwindDataSet.xsd, .xsc, and .xss, but doesn't create the the NorthwindDataSet.Designer.vb file for a typed NorthwindDataSet. (This problem doesn't occur with the Orcas Data Source Wizard running under virtualized Windows Server 2003 R2.)

10. When I attempted to generate a typed data set from Northwind.sdf with the Data Source Configuration Wizard under virtualized Vista, I received this informative error message:

This message has nothing to do with SSCE. It also occurs when attempting to create a typed DataSet from SSCE or SQL Server [Express] with the Data Source Configuration Wizard under Vista in my configuration. A search for the error message returns a link to this even less informative suggestion from the MSDN Library: "Inspect the error message and check for any errors in the Task List (Visual Studio) that can be fixed."

11. I received this error message when attempting to save any changes, such as adding the DataRelationship between the Orders and Order Details tables to the DataSet Designer for the client SSCE database's typed DataSet. This exception occurs under virtualized Windows Vista and virtualized Windows Server 2003 R2:

12. I set the sync interval to 5 minutes, but was unable to detect any evidence that synchronization was occurring between the SSCE client and SSX server.

Subsequently, I wrote a Sync Services test harness to add the DataRelation for the client and a customized SyncGroup at runtime. A future blog post and Visual Studio Magazine article will provide more details on the test harness.

I plan to redo the test drive with virtualized Windows XP SP2 after I finish the test harness studies.

Friday, March 16, 2007

New "Inheritance in the Entity Framework" Article

Erick Thompson has posted a brief article entitiled "Inheritance in the Entity Framework" to the ADO.NET Team blog. Topics include:

  • Why OOP?
    • Problem Modeling
    • Application Extension
  • How the Entity Framework bridges the gap
    • Table per Hierarchy
    • Table per Type
    • Table per Concrete Type

Erik provides sample Entity Data Model (CSDL conceptual schema) XML fragements for Product, DiscontinuedProduct and SeasonalProduct entity types to illustrate how to implement inheritance in ADO.NET 2.0's Entity Framework.

P.S. The Entity Framework's Persistence Ignorance issue discussed in my earlier post is raising more contoversity. Check the original post for updates.

Wednesday, March 14, 2007

Persistence Ignorance Is Bliss, but Is It Missing from the Entity Framework?

A brief item that appeared yesterday afternoon in Danny Simmons's system.data.objects dev guy blog led me to the March 13, 2007 "Persistence Ignorance in the Entity Framework" post by Chris Moore (a.k.a. NTDeveloper) in the ADO.NET Orcas forum. The post is a copy of a March 8, 2007 comment to Shyam Pather's "Using Stored Procedures for Change Processing in the ADO.NET Entity Framework" post in the ADO.NET Team blog.

One of the primary features of object/relational mapping (O/RM) tools, such as the Entity Framework, is persisting domain object (entity) instances as rows in relational database tables. Jimmy Nilsson*, the author of Applying Domain-Driven Design and Patterns: With Examples in C# and .NET, defines the term persistence ignorance (PI) as a property of "ordinary classes where you focus on the business problem at hand without adding stuff for infrastructure-related reasons. ... The classes should focus on the business problem at hand. Nothing else should be in the classes in the Domain Model."

Chapter 6, "Preparing for Infrastructure," of Nilsson's book states on page 184:

[I]f you use a PI-based approach for persistent objects, there’s no requirement to do any of the following:

    • Inherit from a certain base class (besides object)
    • Only instantiate via a provided factory
    • Use specially provided datatypes, such as for collections
    • Implement a specific interface
    • Provide specific constructors
    • Provide mandatory specific fields
    • Avoid certain constructs
    • [W]rite database code, such as calls to stored procedures

The preceding language implies that requiring any of the above elements prevents implementing an object persistence layer that qualifies as persistence ignorant.

Chris takes the following issues with the ADO.NET 3.0 Entity Framework's implementation in the Orcas March 2007 CTP:

  1. Entities must subclass the Entity framework class, and
  2. It is necessary to attach various attributes to entity properties.

Both of which violate Nilsson's PI principles.

Kevin Hoffman, who has compared the August 2006 CTP of the .NET Entity Framework with Ruby on Rails' ActiveRecord, adds his PI objections in this shortened entry:

Getting us "partly there" seems to be a big theme in the Entity Framework. Virtually all of the features that I like about the EF are about 75% of what I want them to be. One such feature is Persistence Ignorance. In a true entity model, I should, in theory, be able to take the model of my entities, complete with ability to create a runtime graph of that model - and go and load data from 3 different stores (XML, Access, or SQL Server) and not change a single line of code. [Emphasis added.]

Microsoft describes the Entity Framework/Entity Data Model as an OR/M—not a domain model management (DMM)—tool, so expecting the capability to substitute an arbitrary XML storage schema for a relational schema is asking a bit much, in my opinion. (Typed DataSets handle persistence to XML files reasonably well, although not in the same way as an O/RM tool.) Substituting Access, Oracle or DB2 for SQL Server would require specifying the appropriate OLE DB provider by changing connection strings. In this case, you'd lose the performance advantages of .NET managed providers for all but Access (Jet) databases. However, it's unlikely that anyone would use compatibility with Jet databases as a criterion for choosing an OR/M tool.

According to Danny Simmons' forum answer to Chris and Kevin's post (abridged):

    1. The requirement that entity classes inherit from a single base class: This is a restriction we are actively working on removing, and in a future CTP you will be able to create your own data classes which do not inherit from one of our framework classes but instead just implement a set of interfaces that define the minimal functionality required for successful interaction with the framework.
    2. The requirement to attach attributes to properties on your entity objects: The long-term idea is to have two separate opportunities for abstraction: First, there is the mapping provided by EntityClient which separates your conceptual model from the store format. The second abstraction opportunity is between the data classes (your objects) and the conceptual schema. For Orcas we have scoped the problem down and require that the mapping at this layer be 1-to-1.

It is true that we don't allow complete persistence ignorance in that we don't support true, plain-old-CLR objects [POCO] with absolutely no knowledge of persistence--you have to expose to the framework which properties and classes actually need [to be] persisted.

Jimmy addresses the issues of .NET attributes in a note on page 188:

Something that has been discussed a lot is whether .NET attributes are a good or bad thing regarding decorating the Domain Model with information about how to persist the Domain Model.

My opinion is that such attributes can be a good thing and that they don’t really decrease the PI level if they are seen as default information that can be overridden. I think the main problem is if they get too verbose to distract the reader of the code.

Danny says in his 3/13/2007 blog post:

Unfortunately I don't have the time right now to write up a full treatment of this subject, but it's important, and it just came up in the Orcas ADO.Net forum. I took a quick stab at it in a response to a question there, and I don't want to lose track of this idea for future treatment.

and in a 3/15/2007 forum post:

It's my intention to try to write up a fairly detailed response because this is such an important topic. Unfortunately I'm driving hard toward a deadline right now so this is going to have to be delayed a few days. I just wanted to let you know that I haven't forgotten, and I will respond.

I'm looking forward to Danny's "future treatment" as well as commentary by .NET O/RM competitors: Frans Bouma (LLBLGen Pro), JBoss/Redhat (NHibernate), Mats Helander (NPersist), Paul Wilson (WilsonORMapper) and others.

Note: Paul offers downloads of his LINQ and O/R Mapping presentation and introductory ORMapper and NHibernate examples.

Major Update 3/16/2007: Sam Gentile's ADO.NET 3 - Entity Framework without Persistance Ignorance post quotes Ayende Rahien's post of almost the same name that take's Microsoft's ADO.NET Team to task for ignoring (or failing to fully support) Persistance Ignorance. (Be sure to read the comments, especially about designers and generated code.) Sam says that he and and his cohorts (Jeremy Miller, Scott Bellware, Jeffery Palermo, raymond lewallen, Jean Paul Boodhoo and James Kovacs) plan to teach the team about NHibernate at the Most Valuable Professional (MVP) global conference (Microsoft 2007 MVP Global Summit) this week.

Jeffrey Palermo (C# MVP) says in his Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300 post:

I have email addresses for several people on the team, and I'll be letting them know what is so compelling about NHibernate and why the above issues have to be resolved before RTM and not after. ...

I want Linq to Entities to succeed. I want frameworks and tools to continually get better; therefore, I will be communicating with the product team to voice my strong concerns over the current direction.

Of course Entity Framework/LINQ to Entities isn't "Microsoft's first go at O/R Mapping." That was ObjectSpaces, which died in the Whidbey (VS 2005 beta) era. Click here for previous OakLeaf posts obout the rise and fall of ObjectSpaces and see, especially, The Language Integrated Query (LINQ) Project (September 2005).

In a 3/16/2007 comment to his LINQ to Entities post, Jeffry says:

I don't think there is any documentation yet, just the bits. I spoke with the Entity Framework architects today, and the roadmap is actually quite bright, so I'm less concerned now. I think they are on the right track, but it will take a while, so don't expect to have your domain-centric O/R mapper in Orcas. I'm not sure what I can disclose, but I'll find out and blog an update.

You can watch Channel9's "ARCast - NHibernate" segment with NHibernate expert Ben Day. Ben will present "Building ASP.NET Database Applications with NHibernate" at 1005 Media's VSLive San Francisco and VSLive Orlando.

Jeff Perrin weighs in with a Persistence Ignorance post and a link to an 2005 O/R Mapping: Attributes vs. XML For Mapping entry that connects to Steve Eichart's If Attributes are good enough for Indigo why aren't they good enough for O/R Mappers? post. Steve discusses the [DataContract] attribute that Indigo (WCF) now shares with ADOEF and Chris Moore wants removed or made optional. According to Danny, they are present to help automate WCF serialization and are optional.

Update 3/16/2007: Minor edits and a brief addition.

Note: Mats' Attributes In NPersist post describes a new NPersist feature that enables substituting attributes for metadata in ObjectMapper's XML files. NHibernateEg provides a method for substituting .NET attributes for NHibernate's .hbm.xml files.

* Jimmy Nilsson is a widely respected .NET and database developer with 20 years of experience. He owns and runs the Swedish consulting company JNSystemKonsult AB. In addition to Applying Domain-Driven Design and Patterns: With Examples in C# and .NET, he wrote .NET Enterprise Design with Visual Basic .NET and SQL Server 2000 in 2001. He's also written numerous technical articles and is a well-known trainer and conference speaker. His "current pet project is called NWorkspace and is (or, at least, might become) what I call adapters for different persistence solutions. Nope, it's not another OR Mapper for .NET, which might come as a shock! Instead, what NWorkspace does is try to reuse the functionality of the current OR Mappers." He now says that LINQ is a better NWorkspace—"I quite often receive enquiries about when I'm going to publish NWorkspace, but I'm still hesitant to do so as it's definitely not of publishable quality. Yet it occurred to me that to a great extent LINQ is largely what the vision of the querying part of NWorkspace was all about. Of course LINQ is way, way better and way more complete. "

Update 3/28/2007: Danny Simmons says there will be A delay before I write more about persistence ignorance... so he can more carefully consider his reply. Danny also posted Change Tracking Mechanisms for the Entity Framework, which covers alternative approaches to change tracking, which is based on values designated "concurrency tokens."

C# MVP Scott Bellware contributes Entity Framework Challenges, an essay arguing against the data-centricity of the current Entity Framework design:

When I work with the Entity Framework I feel trapped in a data guy's perspective of what a framework for behavioral business objects should be.

An entity from the perspective of a data guy is a chunk of data; something that is loosely akin to a row in a table or a row in a view (although that's a bit of an over-simplification). To an application programmer working with entity-centric code, an Entity is a chunk of behavior that can also hold on to its data. ...

The Entity Framework must undergo significant change before it no longer presents impediments to behavior-driven development practices for behavior-centric objects. The framework is an important step forward for the Microsoft data access strategy, but it's only a baby step forward in terms of the frameworks, practices, and expectations that Microsoft customers already have. ...

I'm still committed to the Entity Framework, but it's frustrating to have to turn back the clock on some of the more effective practices that my team has for ensuring success with application-level entity programming. I hope that more interaction between the Entity Framework team will bring about a framework that allows for and even enhances contemporary application development practices in .NET.

I wonder if Scott will remain that committed to the Entity Framework if the EDM Designer doesn't arrive by Orcas RTM.

Another C# MVP, John Papa, argues in Entity Framework Thoughts:

In its current state the Entity Framework can be generated from an existing data model (or can be created by hand with XML). The data team at Microsoft knows this is a limitation and is working on solutions to make building and tweaking entities, mapping the conceptual model to a logical model, and overall design of the EDM much more fluid. I am very excited about seeing what they produce on this end.

Be sure to read the flurry of comments that ensued.

Here's an early (9/13/2006) ADO.NET Team post by Atul Adya that explains Entity Mapping in ADO.NET vNext in considerable detail and discusses the View Generator (a.k.a. Mapping Compiler), Mapping Views, and Query Mapping (QM) views, which refers to an earlier Queries in ADO.NET vNext post by S. Muralidhar (Murali).

The Last Word (4/24/2007) on the Entity Framework discussion at the MVP Summit by Jeremy D. Miller: LINQ for Entities is NOT the O/R Mapper I want today, but might be if and when they... is the best and most reasoned exposition of the current issues developers have with LINQ to Entities and the Entity Framework: "[T]he intrusiveness of Linq for Entities into your Domain Model classes, the general clumsiness of the configuration model as it is right now, and the mechanisms for tracking object state." Be sure to read the comments and then check out Scott Bellware's On Being the "NHibernate Mafia" post.

Tuesday, March 13, 2007

Yet Another Primer on New Language Features in Orcas

Microsoft's Scott Guthrie has joined the choir of bloggers* serializing items about the new language features implemented by Visual Studio vNext, a.k.a., Orcas. Most articles in these series are devoted entirely to C# 3.0, some give a nod to VB 9.0 here and there, and a very few cover VB 9.0 only. An obvious inference is that LINQ afficianados are inclined to (re)iterate IEnumerable<linqPost> rather than IEnumerable(Of LINQPost).

Scott introduces his series with this description [emphasis added]:

In addition to all the great new framework and tool features, one of the things that I think developers (of all .NET application types) will really love about Orcas are some of the new language features and improvements that are coming to both VB and C#. These language changes are going to improve our development experience in both subtle and dramatic ways, and will really improve productivity and reduce the amount of code we need to type.

Over the next few weeks I'm going to try and blog about several of these language improvements, and show how they can be used together to produce some really powerful results.

Following are links to the complete set of Scott's posts (Updated May 15, 2007):

There's an earlier item about Scott's May 2006 Using LINQ with ASP.NET (Part 1) post and a followup article, Using DLINQ with ASP.NET (Part 2). Both parts are C#-only.

One of the issues I plan to explore in the next few months is whether reducing "the amount of code we need to type" improves programmer productivity and the extent to which it affects the cost to maintain code over the application lifecycle. LINQ's enhanced query syntax clearly requires more keystrokes than using C# lambda expressions; the forthcoming VB lambda syntax will be more verbose. Obviously, VB's With ... End With construct, which isn't available in C#, is a dramatic time and keystroke saver, as is the shorthand declaration, Dim objVar as New WhateverType for C#'s whateverType objVar = new whateverType. However, if the number of keystrokes required to achieve the desired result is the criterion of language efficiency, we'd all be writing APL.NET.

*Links to Other Series on New Orcas Language Features and LINQ

Microsoft added most new Orcas language features to support LINQ. Thus the majority of serial expositions of new C# 3.0 or VB 9.0 syntax include references to or examples of one or more LINQ flavors. Here are links to recent OakLeaf items that describe other LINQ/language-related series:

Mike Dodaro's series qualifies only because future items might cover LINQ to Entities.

Following are some series (or equivalents) that don't have their own OakLeaf posts:

Update 5/29/2007: Scott Guthrie started another LINQ series on , this time covering LINQ to SQL:

This series adds VB examples to Scott's traditional C# sample code. (Thanks, Scott.) I'll add later members of the series as they appear.

Update 6/6/2007: UK developer Granville Barnett delivers this series (each of which includes a substantial amount of C# code) on the DotNetSlackers site:

Hooked on LINQ (C#) by Troy Magennis is a wiki, not a blog, but it contains more than 100 pages of C# code examples.

Kevin Hoffman's .NET Addict's Blog (C#) has several posts on LINQ topics, including a Dr. Dobbs article, "LINQ to Web 2.0," and LINQ to XAML and LINQ to SharePoint examples.

Andrew Matthews appears to have a "How LINQ Works" series in the making:

are among his several posts on C# and LINQ topics.

Alex Thissen was one of the early authors of a blog series on C# 3.0:

  1. C# 3.0 for mere mortals, part 1: Extension methods (3/26/2006)
  2. C# 3.0 for mere mortals, part 2: Implicit typing (3/28/2006)
  3. C# 3.0 for mere mortals, part 3: Anonymous types (6/14/2006)
  4. C# 3.0 for mere mortals, part 4: Object and collection initializers (7/16/2006)
  5. C# 3.0 for mere mortals, part 5: Lambda expressions (11/7/2006)
  6. C# 3.0 for mere mortals, part 6: Expression trees (missing)
  7. C# 3.0 for mere mortals, part 7: Query expressions (missing)

In part 5, Alex described his unfinished opus as "the longest running series on C# 3.0."

Microsoft UK evangelist Daniel Moth's posts aren't members of a formal series, but he suggests reading them in order:

  1. LINQ
  2. Local Variable Type Inference (and the VB version)
  3. Object Initiliasers
  4. Anonymous Types
  5. Extension Methods
  6. Lambda Expressions (and the VB version)
  7. Decomposing LINQ (includes Query Expressions)

It's encouraging to see at least some VB coverage in language-oriented posts. Daniel's "Language Enhancements and LINQ" slides for Microsoft UK's Technical Roadshow 2007 (in .pptx format) also include a smattering of VB.

Update 4/9/2007: Earlier C# 3.0 and LINQ Series

Several C# 3.0 and LINQ series originated from the LINQ May 2006 CTP. For the sake of completeness, following are some representative examples:

Sahil Malik's seven-part "Demystifying C# 3.0" sequence consists of brief ("five-minute") examples of the following C# 3.0 concepts:

  1. Demystifying C# 3.0 - Part 1: Implicitly Typed Local Variables "var"
  2. Demystifying C# 3.0 - Part 2: Anonymous Types
  3. Demystifying C# 3.0 - Part 3: Extension Methods
  4. Demystifying C# 3.0 - Part 4: Lambda Expressions
  5. Demystifying C# 3.0 - Part 5: Object and Collection Initializers
  6. Demystifying C# 3.0 - Part 6: (LINQ) Query Expression Translation (to C# 3.0)
  7. Demystifying C# 3.0 - Part 6: Expression Trees

Sahil extended his "Demystifying" approach to LINQ to SQL (then DLinq) with:

  1. An Introduction to DLinq
  2. Setting Up a DataContext Class
  3. Querying for Data using DLinq
  4. Stored Procedure and UDF support in DLinq
  5. Stored Procedures that return a Definite Shape with DLinq
  6. Stored Procedures that return a Variable Shape with DLinq
  7. DLinq: Submitting your Changes

Bill Wagner delivered the following posts about DLinq's technique for translating LINQ queries to T-SQL statements and other related topics:

  1. LINQ to SQL Introduction
  2. LINQToSQL: Translating C# to SQL
  3. LINQ For SQL Queries: Where Clauses and Database Queries
  4. LINQ for SQL Queries: Mathematics Functions
  5. LinqToSql: Joins (9/13/2006)
  6. Linq2SQL: Group By Order By, and why I prefer C# To T-SQL (9/28/2006)
  7. LINQ 2 SQL Set Operations (10/6/2006)
  8. Paging output with Linq2SQL (10/14/2006)
  9. First Commentary on LINQ vs. Python (10/17/2006)
  10. Updating Database Content using Linq2SQL (11/1/2006)
  11. LINQ to SQL: Optimistic ConcurrencyL (12/4/2006)
  12. More LINQ 2 SQL: Object Identity and Nullable Queries (2/26/2007)

Note: The two preceding lists (except Bill Wagner's dated posts) are from Scott Guthrie's Understanding LINQ to SQL Query Translations post of September 1, 2006.

Update 4/12/2007: Eric White's Query Composition using Functional Programming Techniques in C# 3.0 is an October 2006 tutorial about taking the FP approach to writing LINQ queries that's based on the LINQ May 2006 CTP. Eric says:

It is certainly possible to write simple LINQ queries without using these techniques, but as soon as you start writing more complicated queries, you need to understand these techniques.

Eric explains query expressions, lambda expressions, extension methods, local variable type inference, object and collection initializers, tuples and anonymous types, the yield keyword, lazy evaluation, and aggregation more eloquently and in more detail than most other authors.

Update 3/19/2007: Mike Taulty's Deconstructing LINQ item offers an all-in-one-post series of 10 brief elements with "codelets" that demonstrate most new C# 3.0 language features. Mike is a Microsoft UK evangelist "involved in getting information out to developers about what's happening with the Microsoft platform through online mechanisms like newsletters, blogs, videos and through offline mechanisms such as technical sessions."

If you know of any more LINQ-based series in the making, especially posts that provide VB 9.0 code samples, please leave a comment.