Linq to XML Sub-queries

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi:<br/> I am working with the Ajax toolkit Cascading drop-down example. The CarsService.xml xml source is in the app_data dir.<br/> <br/> I need to construct 3 linq queries for the 3 dropdowns. The following is the first:<br/> var q = from c in carservice.Root.Elements("make")<br/> select (string)c.Attribute("name");<br/> In the the following "make" is assigned a value from the above dropdown (for example "BMW"). The following kind of works, but is just wrong because, it requires [0] to get to the car makes (for example of "BMW", it should return "Series 3", "Series 5", "Series 7"):<br/> var q = (from _makes in carservice.Root.Elements("make")<br/> where (string)_makes.Attribute("name") == make<br/> select _makes.Elements("model").Attributes("name")).ToList();<br/> So, I am looking for help on the model and color queries. I expect to have to do sub-queries.<br/> Phil<br/><hr class="sig PHuhn

View the full article
 
Back
Top