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):
- New C# "Orcas" Language Features: Automatic Properties, Object Initializers, and Collection Initializers (3/8/2007) includes references to VB, but all sample code is C#
- New "Orcas" Language Feature: Extension Methods (3/13/2007) mentions VB three times, but includes no VB sample code
- New "Orcas" Language Feature: Lambda Expressions (4/8/2007) provides examples of simple lambdas, as well as lambda expressions compiled as query trees.
- New "Orcas" Language Feature: Query Syntax (4/21/2007) explains C#'s SQL-like from ... in ... where ... orderby ... select syntax with LINQ to Objects and LINQ to SQL examples.
- New "Orcas" Language Feature: Anonymous Types (5/15/2007) describes shaping data to your application's requirements with the var keyword and anonymous types.
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:
- LINQ to DataSet Documentation Series (C#) by Erick Thompson
- VB 9 Extension Methods Documentation Series (VB) by Scott Wisniewski
- Streaming with LINQ to XML Series (C#) by The XML Team
- LINQ Farm Series (C#) by Charlie Calvert
- New Entity Data Model 101 Documentation Series by Mike Dodaro
- CyrusN's C# 3.0 and LINQ Tutorials (C#) by Cyrus Najmabadi
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:
- Using LINQ to SQL (Part 1: What is LINQ to SQL) - 5/19/2007
- Using LINQ to SQL (Part 2: Defining Our Data Classes) - 5/29/2007
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:
- Introducing LINQ – Part 1 covers new language enhancements in C# 3.0 (3/12/2007)
- Introducing LINQ – Part 2 describes how to use LINQ to SQL's graphic Object/Relational designer to map tables to entities (4/11/2007)
- Introducing LINQ – Part 3 shows you how to use stored procedures with LINQ to SQL (4/25/2007)
- Introducing LINQ – Part 4 provides an example of a three-tier LINQ to SQL application with a LINQ to SQL data access layer (DAL), simple business logic layer (BLL), and an ASP.NET AJAX presentation layer (PL)
- Introducing LINQ - Part 5 explains the DataContext class in depth through a series of examples and explanations
Andrew Matthews appears to have a "How LINQ Works" series in the making:
- How LINQ Works - Creating Queries (12/15/2006)
- How LINQ Works - IQueryable (11/18/2006)
- How LINQ Works – Where (11/14/2006)
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:
- C# 3.0 for mere mortals, part 1: Extension methods (3/26/2006)
- C# 3.0 for mere mortals, part 2: Implicit typing (3/28/2006)
- C# 3.0 for mere mortals, part 3: Anonymous types (6/14/2006)
- C# 3.0 for mere mortals, part 4: Object and collection initializers (7/16/2006)
- C# 3.0 for mere mortals, part 5: Lambda expressions (11/7/2006)
- C# 3.0 for mere mortals, part 6: Expression trees (missing)
- 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."
- Local Variable Type Inference (and the VB version)
- Object Initiliasers
- Anonymous Types
- Extension Methods
- Lambda Expressions (and the VB version)
- 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:
- Demystifying C# 3.0 - Part 1: Implicitly Typed Local Variables "var"
- Demystifying C# 3.0 - Part 2: Anonymous Types
- Demystifying C# 3.0 - Part 3: Extension Methods
- Demystifying C# 3.0 - Part 4: Lambda Expressions
- Demystifying C# 3.0 - Part 5: Object and Collection Initializers
- Demystifying C# 3.0 - Part 6: (LINQ) Query Expression Translation (to C# 3.0)
- Demystifying C# 3.0 - Part 6: Expression Trees
Sahil extended his "Demystifying" approach to LINQ to SQL (then DLinq) with:
- An Introduction to DLinq
- Setting Up a DataContext Class
- Querying for Data using DLinq
- Stored Procedure and UDF support in DLinq
- Stored Procedures that return a Definite Shape with DLinq
- Stored Procedures that return a Variable Shape with DLinq
- 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:
- LINQ to SQL Introduction
- LINQToSQL: Translating C# to SQL
- LINQ For SQL Queries: Where Clauses and Database Queries
- LINQ for SQL Queries: Mathematics Functions
- LinqToSql: Joins (9/13/2006)
- Linq2SQL: Group By Order By, and why I prefer C# To T-SQL (9/28/2006)
- LINQ 2 SQL Set Operations (10/6/2006)
- Paging output with Linq2SQL (10/14/2006)
- First Commentary on LINQ vs. Python (10/17/2006)
- Updating Database Content using Linq2SQL (11/1/2006)
- LINQ to SQL: Optimistic ConcurrencyL (12/4/2006)
- More LINQ 2 SQL: Object Identity and Nullable
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.