Welcome to DevAuthority.Com Sign in | Join | Help

Wooley's Wonderings

Insights and observations about VB and .Net technologies. Here we focus on Language Integrated Query (LINQ) which is being featured in the next version of Visual Studio 2008 (formerly known as "Orcas").




<April 2006>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Post Categories

News


MVP Profile
My Books:
LINQ in Action
My BlogMap
Add to Technorati FavoritesMore blogs about linq.

Navigation

Atlanta area bloggers

My Sites

LINQ

Syndication


XLinq Rocks Because

I’m in the process of finalizing a number of presentations on LINQ. I will be posting the demos and slides soon. As a teaser, here’s a quick snippet from the XLinq demo. I begin by showing the new functional construction syntax for XLINQ.

   'Uses Functional Construction
        Dim x As New XElement("LinqEssentials", _
            New XElement("Category", "LINQ"), _
            New XElement("Category", "DLINQ"), _
            New XElement("Category", "XLINQ"))
        Dim y As New XElement("LanguageFeatures")
        y.Add(New XElement("release", New XAttribute("version", "2.0"), _
            New XElement("feature", "Generics"), _
            New XElement("feature", "Iterators"), _
            New XElement("feature", "Anonymous Delegates"), _
            New XElement("feature", "Nullable Types") _
            ))
        y.Add(New XElement("release", New XAttribute("version", "3.0"), _
            New XElement("feature", "Implicit Types"), _
            New XElement("feature", "Extension methods"), _
            New XElement("feature", "Lambda Expressions"), _
            New XElement("feature", "Object initializers"), _
            New XElement("feature", "Anonymous Types"), _
            New XElement("feature", "Expression Trees") _
            ))
        y.Add(New XElement("release", New XAttribute("version", "9.0"), _
            New XElement("feature", "dynamic interfaces"), _
            New XElement("feature", "dynamic identifiers"), _
            New XElement("feature", "XML Literals") _
            ))
        Dim z As New XElement("XLinqRocksBecause")
        z.Add(x)
        z.Add(y)

        Debug.Write(z)

While it is elegant and  lets you work more directly with the document structure, the c# method is not quite as cool as the VB one. In the demo, I run the first code snippet, then copy the output from the debug.write method which sends out the XML nicely formatted. Then you create a new variable and paste in the output from the debug.write call as follows:

  Dim x = <VBXLinqRocksBecause onDate=<%= Today %>>
                    <LinqEssentials>
                        <Category>LINQ</Category>
                        <Category>DLINQ</Category>
                        <Category>XLINQ</Category>
                    </LinqEssentials>
                    <LanguageFeatures>
                        <release version="2.0">
                            <feature>Generics</feature>
                            <feature>Iterators</feature>
                            <feature>Anonymous Delegates</feature>
                            <feature>Nullable Types</feature>
                        </release>
                        <release version="3.0">
                            <feature>Implicit Types</feature>
                            <feature>Extension methods</feature>
                            <feature>Lambda Expressions</feature>
                            <feature>Object initializers</feature>
                            <feature>Anonymous Types</feature>
                            <feature>Expression Trees</feature>
                        </release>
                        <release version="9.0">
                            <feature>dynamic interfaces</feature>
                            <feature>dynamic identifiers</feature>
                            <feature>XML Literals</feature>
                        </release>
                    </LanguageFeatures>
                </VBXLinqRocksBecause>

Notice, there are no quotes around any of this. Accessing an element can be as simple as the following (note, you will need to turn Option Strict OFF for this one to work).:

Console.WriteLine(CStr(x.@onDate)

While I think LINQ and XLINQ are cool, I must applaud the VB/XML/DATA teams for their efforts on this one. Finally XML in VB ROCKS!

If you want to learn more, head on over to the LINQ center on MSDN, or come to my talks at the Alabama Code Camp, Atlanta Dotnet User Group, or Atlanta Code Camp over the next few weeks.

Published Monday, April 17, 2006 7:44 PM by jwooley
Filed Under:

Comments

# http://xlinq.net/ @ Friday, April 21, 2006 10:12 PM

jwooley

# re: XLinq Rocks Because @ Friday, May 19, 2006 7:08 AM

Thanks for showing me this last night Jim. This is cool stuff!

Josh Gough

# LINQ Links @ Monday, June 05, 2006 11:24 AM

I typically try to avoid making link blog posts, but wanted to call your attention to a couple good posts...

Wooley's Wonderings

# We know that XLinq rocks, but .... @ Wednesday, June 07, 2006 11:04 PM

As much as I&amp;nbsp;appreciated Jim Wolley's response to a post on the xmlteam blog ...

XLINQ is so...

mikechampion's weblog

New Comments to this post are disabled

Powered by Community Server, by Telligent Systems