LINQ to XML 8211 really interesting
A lot of people tend to consider linq2sql the most important provider for linq, this is not true for me. First of all I tend to prefer NHibernate over Entity Framework and LINQ2SQL, and moreover I think that Linq 2 XML really rocks.
If you worked like me with XML you probably are frustrated of the many api you have to deal with: you have to know XPATH 1.0 and 2.0, XSL for transformation, DOM is useful too, and.NET really has a lot of classes to work with XML, and not all of them are really simple to use.
LINQ2XML solves a lot of problem, is a unifying API to get data from, create, and transform XML data. Let suppose you have such an XMl
|
|
This is the XML you can get from northwind database with a simple
|
|
Now if you want to select id, name and orders number for all customer that has more than 10 orders you can do this query.
|
|
It is simple, it has nothing to do with XPATH or similar stuff, you have intellisense, and it works :D. If you want to transform that XML.. no more xsl pain :D
|
|
Whoa…… It seems to me that LINQ2SQL can really make my life better.
Alk.