Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

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

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


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")


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

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):


var q = from o in _data.JobCandidates

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

           select o.Resume.Name.Name_Last;


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

           ).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.

Rate this Article