Microsoft Sudoku
LINQ Part 5 - Custom Extension Methods

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.


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


Feed You can follow this conversation by subscribing to the comment feed for this post.


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

Kamran Shahid

Looking LINQ I also thought about the same type of implmentation of Xquery. Any was nice sample for comparison


It's a Very helpful article for me. Actually, I am fond of reading online punjabi news. Thanks for writing such a complete ..And,I wantn't to miss them.
Thank you for sharing..

thomas sabo

A few days ago I read such articles, but did it this good, with you, share

zolpidem 10mg

It's a Very helpful article for me. Actually, I am fond of reading online punjabi news. Thanks for writing such a complete

Thomas Sabo Australia

I became interested in the topic and I am thinking whether I could use your texts on my paper, of course with the quotation. Please contact with me, thanks very much.

Ray Ban

Very useful, thank you for the info!

Authentic Louis Vuitton

Your article, sensible, I like it very much.If you like
Louis Vuitton T-Shirt for Men Outlet ,come and see it.It's your best choice.

Ray Ban 4086

I recently came across your post and have been reading along. I thought I would leave my first comment. I don't know what to say except that it caught my interest and you've provided informative points. I will visit this blog often.
Thank you,

Coach Outlet Store

Many thanks for all of the enthusiasm to offer such beneficial data right here.Life is a book, in every page leave their wonderful memories.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)