Wednesday, January 18, 2006

Microsoft released the January CTP of the Language Integrated Query (LINQ) project's Visual Basic preview for Visual Studio 2005 on January 17, 2006. The big news is that the January CTP finally adds DLinq support to Visual Basic 9.0. You can download the January bits here. The new CTP replaces the September (PDC 2005) Visual Basic CTP that, unlike the C# version, didn't support DLinq for relational data sources.[Updated 2/7/2006].The January CTP requires the release version of Visual Studio 2005 or Visual Basic Express, and works with SQL Server 2005 or SQL Server Express. (It probably also works with SQL Server 2000 or MSDE 2000, but I haven't tested that capability.) Microsoft hasn't tested the CTP with languages other than English. Although not stated in the Readme page, it's a good idea to use Control Panel's Add/Remove Programs tool to remove the September CTP version before executing Linq VB Preview (Jan 2006).msi. Running the CTP's installer adds a VB LINQ Preview item to your Programs menu with Readme, Visual Basic 9.0 Overview, Visual Basic 9.0 Samples, Visual Basic LINQ Project Overview, and XLINQ Overview choices.

SQLMetal.exe Updated for Visual Basic 9.0

The January CTP's version of the SQLMetal.exe utility creates the DatabaseName.vb class file that's necessary for mapping an SQL Server resultset to a LINQ object. (The September CTP's SqlMetal.exe didn't work with the /language:vb switch.) Later VB 9.0 versions will add a designer to simplify generating the mapping class file.

To create a Northwind.vb class file with nwind as its namespace by attaching the Northwind.mdf file in the C:\Program Files\VB LINQ Preview\Samples\Sample Queries\SampleQueries folder to your default SQL Server 2005 instance, execute the following from the "\Program Files\VB LINQ Preview\Samples\Sample Queries\SampleQueries folder:

If you've already added a Northwind database to your default SQL Server instance, you receive a "Failed to attach an auto-named database for file northwind.mdf. A database with the same name exists ..." or "A connection was successfully established with the server, but then an error occurred during the loginprocess. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)" exception.

In this case, execute the following to create the class file from the server and database you specify in the following example, which assumes SQL Server Windows authentication:

According to the January CTP's Readme page, the CTP adds the following new features to the September release:

LINQ Intellisense: Query statements now have statement completion, Intellisense, and Pretty Printing to improve overall discovery and readability of VB queries.DLinq Support: Previous tech previews of the LINQ CTP did not fully support leveraging the DLinq technology which is for querying against relational data stores, such as SQL Server. DLinq support in this release is limited in that only the working query syntax over objects will extend to DLinq.
Editing support for XML Literals: The Visual Basic background compiler provides immediate feedback, with this release this support has extended to integrated XML. Specifically, XML literals are now automatically indented and XML literals plug into auto-correction. The XML literals are now completely colorized with customizability through the VS 2005 Options, Fonts and colors.

The following new features apply to XML late-binding:

Importing XML Namespaces: XML namespaces can be imported to the VB program using similar mechanism to importing CLR namespace.Accessing Elements with Namespaces: Once an XML namespace is imported, you can use qualified identifiers to access elements with namespaces. Indexer for IEnumerable(Of T): An indexer was added to IEnumerable of any type. This enables easy access to any element from a generic IEnumerable, specifically for accessing the first XElement from the XElements collection that is returned from XML late binding expressions.

Paul Vick Summarizes New January CTP Features

Paul's February 6, 2006 post on the availability of the January CTP was a bit late, but his informal summary of the new DLinq and XLinq features is quite useful:

We now support some Intellisense for Select expressions. This is a step forward in our investigation of the Select/From vs. From/Select question, so we’re definitely interested in feedback here.

We now support a lot more LINQ, specifically DLinq and variable capture (so you can now access local variables in queries). A huge chunk of my November/December went towards implementing lambda expressions and expression trees in Visual Basic and that, combined with some excellent work by another team member on variable capture, means a lot of stuff works now that didn’t before.

The editing/display experience for XML literals has been greatly enhanced — just having colorization makes a huge difference.

A bunch of extensions were made to the XLinq support to make working with namespaces and elements easier.

Here's a screen capture that demonstrates colorization of part of the code for generating XLinq XML literals with element values obtained with DLinq from the Northwind sample database:Online Demo and NewsgroupPaul Vick and Amanda Silver deliver "Visual Basic Futures: Latest Developments in the LINQ Project", a 10-minute video overview of the objectives of the LINQ project, plus a brief description of January CTP's new and improved DLinq and XLinq features. Amanda continues the presentation with a 20-minute demonstration of DLinq and XLinq in Visual Studio 2005 console applications that demonstrate basic DLinq and XLinq syntax in simple console applications, the LINQ VB Project Sample Query Explorer Windows form project, and a new (but apparently unfinished) visualizer that displays expression trees for LINQ queries, as shown here:

Unfortunately, the expression tree visualizer isn't included with the January CTP bits. Click here to read a trasncript of the overview and demo. You can post questions about the new VB 9.0 features and (hopefully) receive answers on the LINQ (General) newsgroup. The newsgroup's MVPs are mostly—or, more likely, entirely—C# coders. Sample Applications

"More than five years in the re-making, SQL Server 2005 not only addresses shortcomings in high-availability and disaster recovery, but brings sweeping mprovements in almost every area. Management tasks have been streamlined, and monitoring and diagnostics have been beefed up. A default locked-down configuration, data encryption, and other new features strengthen security. Analysis Services, Reporting Services, and data Mining are now fully integrated and mature. DTS (Data Transformation Services) has been rewritten from the ground up, emerging as the more powerful and flexible SQL SSIS (Server Integration Services.)"

He gives SQL Server a score of 9.1 (Excellent) with 9 out of 10 points for managability, performance, availability and scalability, plus 10 points for value. I would have awarded 10 points for managability, which has been SQL Server's forte since version 7.0 introduced the "Starfighter" management tools. Starfighter was the code-name for the first version of SQL Server Enterprise Manager implemented as a Microsoft Management Console (MMC) application.

High-availability (HA) features and disaster recovery capabilities get high marks for mirroring, online restores, and page-level restores. Although McCown noted that mirroring was unsupported in the November 2005 release version of SQL Server 2005, Microsoft promises a supported version in 2006. Online indexing also contributes to HA.

A "Development Snapshot" graphic's Pros section outlines new SQL Server 2005 features for developers, such as CLR integration, new T-SQL constructs, and native XML data storage. The Cons include lack of IntelliSense for T-SQL queries, which Microsoft promised and then reneged, problems with an "unresponsive interface" for SSMS (which I haven't encountered), and more complex queries for DVMs than their "deprecated counterparts." A "Cool Tools for SQL Server Coders" graphic lists the most important T-SQL enhancements. See "Take Advantage of New T-SQL Features" and "Exploit Yukon's XML Data Type" for more details and downloadable Visual Basic 2005 source code examples for these new features. The article doesn't review new SQL Server Service Broker (SSSB) features or native XML Web services capabilities. (See my "What’s New With VS and Data" interview, forthcoming Visual Studio Magazine article on SSSB and August 2005's "Create Interoperable Native Web Services.")

The review concludes with a rehash of what's missing in SQL Server 2005—Intellisense for T-SQL queries, a centralized code repository, and lack of a separate extract, transform, and load (ETL) server—and advice about if and when to upgrade to SQL Server 2005. McCown's closing remarks, however, say it all:

SQL Server 2005 is an excellent release that will gain Microsoft some real respect in the high-end database market. SQL Server’s tools now lead Oracle and DB2 in pretty much every area—management, monitoring, and especially development—and of the three vendors, Microsoft seems to be the most concerned about improving them.

You can read Sean's book reviews on database programming, database and Windows security, and general database topics at his ITBookworm site, and read his advice for DBAs and DBA "war stories" on his DBA Rants blog. Sean is the Senior DBA for SourceCorp of Dallas, Tx, where he lives with his wife and two kids. He's practiced and taught Kenpo for the past 20 years. [Kenpo competency is very useful for DBAs, especially Senior (supervisory) DBAs.]

Through integration with .Net, SQL Server 2005 takes its rightful place as an active peer, not a detached agent, in large-scale distributed applications. ... SQL Server 2005’s .Net integration creates a dream scenario in which SQL developers can incorporate the advanced functionality of .Net in their stored procedures, while C#, Visual Basic, and even JavaScript developers can work with databases as though they were language extensions.

.NET might be the best thing since sliced bread (or Java integrated with competitors' RDBMSs), but native code running in the SQL Server 2005 process has the potential to be the most misused feature in this release. (See the "When to Use SQLCLR" sidebar to my November 2005 "Manage Data With VS 2005" Visual Studio Magazine article.

McCown didn't make an important argument in favor of Express Editions: There is little or no relief from vendor lock-in with "open-source" databases. Migrating databases from MySQL to PostgreSQL or—heaven forbid—HSQLDB is likely to be far more difficult than moving to and from Oracle, SQL Server, DB2, or Sybase. The commercial RDBMS vendors provide tools to accomplish the transation; with an "open-source" database, you're mostly on your own.

McCown wants Microsoft and Oracle to remove the 4-GB size limits from their Express Editions in the hope that doing this will induce Web site owners to migrate from "open-source" to "proprietary" databases. It seems to me that Microsoft and Oracle are delivering much a more useful and stable product than MySQL or PostfresSQL—the two major players in the open-source database market—and neither vendor charges for support. Microsoft provides an Express version of SSMS to handle simple database chores in a Windows UI. Bear in mind that the size limit is per database, not per server, and you can run many named instances of SQL Server Express on a single computer running Windows XP or 2003 Server. (See my May 2005 "Migrate to SQL Server 2005 Express Edition" Visual Studio Magazine article.)

The dual Web role application has been running in Microsoft's South Central US (San Antonio) data center since September 2009. I believe it is the oldest continuously running Windows Azure application.

About Me

I'm a Windows Azure Insider, a retired Windows Azure MVP, the principal developer for OakLeaf Systems and the author of 30+ books on Microsoft software. The books have more than 1.25 million English copies in print and have been translated into 20+ languages.

Full disclosure: I make part of my livelihood by writing about Microsoft products in books and for magazines. I regularly receive free evaluation software from Microsoft and press credentials for Microsoft Tech•Ed and PDC. I'm also a member of the Microsoft Partner Network.