ServicesResourcesConferencesOur TeamWeblogsAboutContact
   

Subscriptions

Post Categories

News

My new books

My Blogroll

INETA UG Leaders

Affiliations

News

Archives

Christian Nagel's OneNotes

.NET Training, Consulting, Coaching & Development


LINQ vs. XQuery

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
   select r;

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
  return $racer

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.

Christian

Via Don: Michael Kay's comparison of XSLT 2.0 and XQuery.

posted on Friday, April 14, 2006 7:36 PM

# New and Notable 96 @ Wednesday, May 17, 2006 5:37 PM

Again another month and change since the last one so this issue will be a collection of everything marked...
Sam Gentile

# New and Notable 96 @ Friday, May 19, 2006 2:54 PM

Again another month and change since the last one so this issue will be a collection of everything marked...
Sam Gentile

# New and Notable 96 @ Thursday, May 25, 2006 2:15 AM

Again another month and change since the last one so this issue will be a collection of everything marked...
Sam Gentile

# New and Notable 96 @ Thursday, May 25, 2006 6:44 AM

Again another month and change since the last one so this issue will be a collection of everything marked...
Sam Gentile

# New and Notable 96 @ Thursday, July 06, 2006 6:38 AM

Again another month and change since the last one so this issue will be a collection of everything marked...
Sam Gentile

# re: LINQ vs. XQuery @ Tuesday, May 01, 2007 7:24 PM

Do you know how well LINQ will perform in querying a large db of XML documents, over 100000 records?
sim


Powered by Community Server, by Telligent Systems