InfoQ

News

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

Posted by Hartmut Wilms on Dec 05, 2007 07:19 AM

Community
.NET
Topics
.NET Framework
Tags
XML,
LINQ,
SQL Server 2005,
XML Schema

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.

2 comments

Reply

Post 2008? by Phillip Calçado Posted Dec 6, 2007 3:04 AM
Re: Post 2008? by Hartmut Wilms Posted Dec 7, 2007 3:05 AM
  1. Back to top

    Post 2008?

    Dec 6, 2007 3:04 AM by Phillip 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

  2. Back to top

    Re: Post 2008?

    Dec 7, 2007 3:05 AM 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

Exclusive Content

Rationalizing the Presentation Tier

Thin client paradigm characterized by web applications is a kludge that needs to be repudiated. Old compromises are no longer needed and it's time to move the presentation tier to where it belongs.

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.