I'm trying to take one attribute to use as the key, and another to use as the value. If I use (xDoc is an XDocument object in the example):
Dictionary<string, XElement> test = xDoc.Descendants()
.Where<XElement>(t => t.Name == "someelement")
.ToDictionary<XElement, string>(t => t.Attribute("myattr").Value.ToString());
I get a dictionary with the myattr value as key (which is what I want) but the entire XElement object as the value.
What I want to do, is to select a second attribute to set as the value property on each dictionary item, but can't seem to figure that out.
Is it possible to do all of this in 1 Linq statement? Curiousity has caught me!
Cheers!