I am working with LINQ to XML in C# and I need to do some sorting on the attributes of my xml nodes. My xml looks something like this.
<root>
<Claim key="1" carrier="carA" zip="34343" pages="1"/>
<Claim key="2" carrier="carA" zip="34343" pages="2"/>
<Claim key="3" carrier="carB" zip="34343" pages="4"/>
</root>
I can sort the xml using the orderby clause such as
var query= from claim in root.Elements("Claim")
let Key = claim.Attributes("Key").First().Value
let Carrier = claim.Attributes("Carrier").First().Value
let CarrierZip = int.Parse(claim.Attributes("CarrierZip").First().Value)
let Pages = claim.Attributes("Pages").First().Value
orderby Pages ascending, CarrierZip ascending, Carrier ascending
select claim;
Then I get a list of the keys from query.
What I want to do is get collections of all the claims with 1 page, then all the claims with 2 pages and so on, but I do not know what the maximum number of pages can be.
can anyone help me out?
EDIT -
I changed my intial thought on how to accomplish this and I now would like the out put to resemble this.
List<List<List<List<int>>>>
All claims
- 1 page
-zip1
-carr1
-int claim key
-int claim2 key
- car2
-zip2
-car1
- 2 pages
-zip1
and so on. The trick is I need to query the nodes and get multiple groups out of it. Can this be done in my statement or is a series of statements required?