BT

Post-VS 2008-Technology: LINQ to XSD and LINQ to Stored XML

by Hartmut Wilms on Dec 05, 2007 |

Today, Shyam Pather, Principal Development Lead on the Data Programmability Team at Microsoft, is giving a presentation on LINQ to XML: Visual Studio 2008, Silverlight, and Beyond at the XML 2007 Conference in Boston. He talks about the current and future technologies surrounding LINQ to XML.

The first two parts of the presentation cover LINQ to XML basics and the current advanced XML features:

  • LINQ to XML classes (XDocument, XElement, XAttribute, XNamespace, XName)
  • VB XML Literals
  • Intellisense Support
  • Helpful Operator Overloads
    • Cast Operator on XElement and XAttribute to bypass .Value property when accessing content
    • Nullable types and null coalescing operator
  • Bridge Classes, which offer System.Xml APIs over LINQ to XML trees

The slides can be downloaded from the conference's web site.

In the third part of the presentation Shyam presents future extensions of LINQ to XML: LINQ to XSD and LINQ to Stored XML.

LINQ to XSD has first been announced by Microsoft's XML team in November 2006 (including a preview alpha 0.1 for the LINQ May 2006 CTP):

LINQ to XSD provides .NET developers with support for typed XML programming on top of LINQ to XML. While the LINQ to XML programmer operates on generic XML trees, the LINQ to XSD programmer operates on typed XML trees -- instances of .NET types that model the XML types of a specific XML schema (XSD). To get an idea, consider the following C#3.0 fragment for a LINQ to XML query that computes the total over the items in a XML tree for a purchase order:

(from item in purchaseOrder.Elements("Item")
select (double)item.Element("Price") * (int)item.Element("Quantity")
).Sum();

 

Using LINQ to XSD, the query is written in a much clearer and type-safe way:

 

(from item in purchaseOrder.Item
select item.Price * item.Quantity
).Sum();

In June 2007 another preview alpha 0.2 for Visual Studio 2008 beta 1 was published. No LINQ to XSD preview appeared for VS 2008 beta 2, probably because Dr. Ralf Lämmel, who spearheaded the technology, left Microsoft. Roger Jennings, principal consultant of OakLeaf Systems, has the details of LINQ to XSD's history. He pursued the matter and requested an update of the technology from Microsoft:

Ralf Lämmel updated his LINQ to XSD implementation that enables strongly-typed LINQ to XML queries from the November 2006 Preview Alpha 0.1 for the May 2006 LINQ CTP to Preview Alpha 0.2 for Orcas Beta 1 on June 5, 2007. Dr. Lämmel then returned to Germany to assume a full professorship in the Department of Computer Sciences of the University of Koblenz (Germany). There’s been no word from the XML Team that’s responsible for LINQ to XML about an update to LINQ to XSD for the final VS 2008 bits. Hopefully, this very useful LINQ implementation won’t disappear as a result of attention attrition.

LINQ to Stored XML (XML in the database) offers ways of issuing queries against XML datatype columns within an SQL Server 2005. The goal is to "provide a strongly-typed LINQ experience over data in XML datatype columns" by providing "mapping from XML schema to classes" and "query translation from LINQ expressions to server XQuery expressions" (sample taken from the AdventureWorks database with 'Resume' being an XML datatype column):

Query:

var q = from o in _data.JobCandidates

           where o.Resume.Skills.Contains("production")

           select o.Resume.Name.Name_Last;

Output:

SELECT [Extent1].[Resume].query(
           N'declare namespace r="http://.../adventure-works/Resume";
           /*[1]/r:Name/r:Name.Last'

           ).value(N'.', N'nvarchar(max)') AS [C1]

FROM  [HumanResources].[JobCandidate] AS [Extent1]

WHERE cast(1 as bit) = ([Extent1].[Resume].query(
           N'declare namespace r="http://.../adventure-works/Resume";
           contains(/*[1]/r:Skills, "production")'

           ).value(N'.', N'bit'))

The presentation is the first sign that activity is continued on LINQ to XSD and that LINQ to Stored XML is underway. But unfortunately no release dates - not even for preview bits - are mentioned.

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Post 2008? by Phil Calçado

Sad that Microsoft's post-2008 plans are about a yet a new way to parse same old XML...

I really thought that I'd find something interesting under this headline.

Phillip Calçado

Re: Post 2008? by Hartmut Wilms

Phillip,

It would be difficult to summarize all MS plans for post VS 2008 technology under a single headline. This is but one topic of their plans, which goes well in line with the evolution of C# and VB (LINQ). X/O-Mapping is an important topic for MS (and others), which in my opinion goes beyond simple XML parsing.

-Hartmut

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT