Welcome Guest!
Create Account | Login
Locator+ Code:

FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly
get the code
more resources

Test Drive VB9 and DLinq
The January 2006 Language Integrated Query (LINQ) preview for the next ("Orcas") version of Visual Basic enables automating SQL Server object-relational mapping for DLinq and enhances XLinq syntax for literal XML and late binding.
Roger Jennings

March 27, 2006

Technology Toolbox: VB.NET, SQL Server 2005, XML, Visual Studio 2005, or Visual Basic or Visual Web Developer Express editions, Visual Basic 9.0 LINQ Technology Preview (January 2006), SQL Server 2005 Express Edition or higher, Northwind sample database

The forthcoming Visual Studio "Orcas" release promises major upgrades to data-management programming with Visual Basic 9.0 and C# 3.0.

Language Integrated Query (LINQ) and its data (DLinq) and XML (XLinq) libraries transform relational data and XML documents into first-class, interoperable CLR objects. My "Streamline Mapping With Orcas and LINQ" article in the VSM December 2005 issue described the "impedance mismatch" caused by mixing literal SQL query strings and XML InfoSet text with .NET's statically-typed data objects. That article covered the initial LINQ technical preview, which Microsoft released in September 2005 at the Professional Developers Conference (PDC). The PDC release represented a major step toward CLR support for a common query language across application objects, relational data, and XML documents, but offered only XLinq support for VB. DLinq for object-relational mapping (ORM) worked in C# projects, but wasn't accessible to VB programmers.


The VB team overcame this lack of VB 9.0 parity with C# 3.0 by delivering an upgraded VB-only technical preview in January 2006. I'll explain the newly added DLinq and XLink features and why they're important to VB developers. I'll also show you how to generate VB classes from SQL Server databases, and describe the article's sample application that shows LINQ, DLinq, and XLinq coding techniques for querying, joining, and updating data objects and XML documents. The sample application includes a Windows Form that demonstrates DLinq databinding with three auto-generated DataGridView controls in a parent-child-grandchild relationship.

Paul Vick, Microsoft's technical lead for the VB language and compiler, says that the VB team has been "working on improving data access in the Visual Basic language" with the focus on two primary areas. First, the team wants to design a unified syntax—based on SQL's SELECT … FROM … WHERE … ORDER BY syntax—for querying application objects, relational data, and XML documents. Achieving this goal should more than compensate for loss of the ObjectSpaces ORM add-in and XQuery 1.0 namespaces that Microsoft dropped from VS 2005 and .NET 2.0. Second, the team intends to simplify production of XML InfoSet documents by embedding XML literals into VB 9.0 code. This feature makes it easy for database developers to generate XML documents in the middle or client tier, without incurring the server resource consumption and network traffic overhead of FOR XML AUTO queries. XLinq gains support for XML namespaces with the Imports statement, whitespace preservation for cut-and-paste insertion of XML document structures into the VB code editor, auto-indentation, auto-correction of closing tags, and code colorizing.

Get started with January's VB-only LINQ upgrade by downloading the LINQ VB Preview (Jan 2006).msi file from the Future Versions page of MSDN's VB Developer Center (see Additional Resources). Running the installer adds a VB LINQ Preview node to your Programs menu, creates and populates a \Program Files\VB LINQ Preview folder with a Readme.htm file and Bin, Docs, and Samples subfolders. It also replaces the RTM version (8.0.50727.42) of the VB compiler with the LINQ-enabled release (8.0.50926.00) and adds LINQ Windows Application, LINQ Console Application, and LINQ Class Library templates to the New Project dialog's Visual Basic Templates pane. Updated System.Query.dll, System.Data.Dlinq.dll, and System.Xml.Xlinq.dll assemblies provide the namespaces for required LINQ, DLinq, and XLinq references. The VB LINQ upgrade runs side-by-side with, and doesn't affect, the November 2005 C# LINQ Preview and sample applications for the VS 2005 RTM version.

Create a new VB LINQ project in VS 2005 or VB Express by choosing the LINQ Windows Application template, which adds to the standard System, System.Data, System.Deployment, System.Drawing, and System.Windows.Forms namespace references to System.Query, System.Data.Dlinq, and System.Xml.Xlinq. Surprisingly, the expected System.Xml namespace reference is missing from the templated project.

Back to top

Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home