blog.mha.dk
The on-line blog of Michael Holm Andersen

Using LINQPad to test your LINQ to XML queries

Sunday, 6 February 2011 12:55 by mha

If you’re a LINQPad user you’re probably used to query your DBML (LINQ to SQL), but did you know that you can also use it for LINQ to Objects, LINQ to XML etc.

A simple example of how to do a query against a XML file (make sure language is set to C# Statements):

var xml = XElement.Load (@"c:\\inetpub\\GWportal\\src\\wwwBackend\\App_Data\\axCache\\
   GWDK\productprice-mha.xml");

var query =
  from e in xml.Descendants("unittransaction").Descendants()
    where (e.Attribute("name").Value == "ItemRelation" && e.Value.Equals("10020"))
  select e.Parent;
 
query.Dump();

Which gives this result:linqtoxml

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

Comments

February 17. 2011 03:50

Easily, the post is actually the freshest subject on how to choose a sleeping bags. I concur with your conclusions and will eagerly appear forward to your incoming updates. Saying thanks will not just be enough, for the wonderful lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.

germanium suppliers

Comments are closed