Home > Microsoft .Net Development News > LINQ and XML programming in Visual Basic 9
Microsoft .Net Development News:
EMAIL THIS LICENSING & REPRINTS

LINQ and XML programming in Visual Basic 9

By Brian Eastwood, Site Editor
13 Jun 2007 | SearchVB.com

.NET News Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google

As Visual Basic 9 nears its year-end release, Microsoft is making a concerted effort to introduce developers to its new features -- notably the Language Integrated Query, or LINQ, but also improved XML support and more intuitive IntelliSense.

At Tech Ed 2007, Amanda Silver, program manager for Visual Basic, demonstrated each of these features to Visual Basic developers. Taken together, she said, they make the release of Visual Basic 9 bigger than VB's move to the .NET Framework.
More on Visual Basic and LINQ
Let's think about LINQ

Visual Basic's future: LINQ, Orcas and, yes, VB 6

How Visual Basic 9, Windows Vista appeal to the Visual Basic 6 developer

LINQ has garnered the most attention among the new features in VB 9.0 and C# 3.0, largely because it allows developers to query anything that is IEnumerable -- objects, datasets, XML and so on.

"We took the query and the transform operations and brought them into VB, and we did it in such a way that the code you write is abstracted away from the data source you are querying over," Silver said.

LINQ offers quite a bit of support for query expressions such as aggregation, partitioning, grouping and ordering. This means that, while the compiler is busy, developers should not be, Silver said: "We do all the heavy lifting. You just need to write the query you need."

These queries, moreover, can take on complex forms. If operations are built up line by line, the compiler will call them sequentially. If a query is issued on top of the results of another query, it is not executed until the results are enumerated, and only one query is issued to the database.

Structurally, LINQ queries are modeled after TSQL queries, with one important difference -- in LINQ, From comes before Select. Ever since LINQ made its debut at PDC 2005, Silver said, the message Microsoft has heard is that "IntelliSense is way more important than staying close to SQL syntax."

Given that IntelliSense now comprises much more than just keywords, such a notion is not surprising.
More on Visual Basic and XML
Using XML in Visual Basic 2005: Chapter 12 of Professional VB 2005

Mini-Guide: Data binding and XML

For example, thanks to Extension Methods, which are defined through attributes and applied to a module, a shared method can be applied as an instance method. In addition, when an object is created and properties are assigned to it, the compiler will infer the object's type, Silver said. Along those same lines, properties need not be specified, either, as the compiler will infer those based on the expression, she added.

These instances of type inference are, by default, turned on for new Visual Studio 2008 projects but turned off for migrated projects.

Developers should also notice that IntelliSense comes in handy when working with XML as well. Bring in an XML document, or copy and paste XML code into Visual Studio, and the IDE will infer its schema, saving it as an .xsd file. Once this file is passed into a VB project, full XML IntelliSense is available "anywhere that expression is valid in Visual Basic," Silver said.

This "functional construction," in which passing a set of arguments to a constructor subsequently passes a query result, is a significant improvement over the current methodology for XML programming, Silver added. This involves describing to the API what a developer is trying to do with the XML, which has to be done in a document.

Sound Off! -   Be the first to post a message to Sound Off!


Tags: .NET Framework 3.5 and Visual Studio 2008 developmentVisual Studio 2008 and Language Integrated Query (LINQ).NET Framework development with XML and XAMLVIEW ALL TAGS

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts