Recently I found an XQuery sample application that I had written for a beta version of .NET 2.0. The XQueryCommand class didn't make it to the release of .NET 2.0.
The current status of the XQuery specification is candidate recommendation (since 3-Nov-2005).
What's the difference between XQuery and LINQ?
In a previous blog post I've shown how to filter and sort using LINQ:
var winners = from r in racers
where r.Wins > 3
orderby r.Wins descending
How can the same be fulfilled with XQuery?
for $racer in doc("racers.xml")/Racers/Racer
where $racer/Wins > 3
order by $racer/Wins descending
The syntax doesn't look that different. So what are the big differences between XQuery and LINQ?
- XQuery is specified by the W3C.
- LINQ is defined by Microsoft.
- LINQ is integrated with .NET languages.
- XQuery requires a separate parser.
- XQuery is a query language for XML data.
- LINQ can be extended by custom methods written in a .NET language.
- LINQ is independent of the data and supports the same syntax for objects, database access, and XML.
In my opinion, having one syntax to query objects, the database, and XML is a really big advantage.