Is This Possible In Linq Aka Really Hard Example For Real Linq Experts |
By Joseph Albahari, Ben Albahari
Price: $49.99 USD
£30.99 GBP
Cover | Table of Contents | Forum
![]() ![]() |
Is This Possible In Linq Aka Really Hard Example For Real Linq Experts |
Mar 18 2008, 10:35 AM
Post
#1
|
|
|
New Member ![]() Group: Members Posts: 1 Joined: 18-March 08 Member No.: 152 |
I have xml coming back from a web service that can look like this:
<books> <book> <owner authorid="1" /> <owner authorid="2" /> <author id="1"> <firstname>john</firstname> <lastname>smith</lastname> </author> <author id="2"> <firstname>mary</firstname> <lastname>jones</lastname> </author> <author id="3"> <firstname>sue</firstname> <lastname>green</lastname> </author> <book> </books> or like this: <books> <book> <owner companyid="3" /> <company companyid="1"> <name>big company 1</name> </company> <company companyid="2"> <name>big company 2</name> </company> <company companyid="3"> <firstname>big company 3>/company> </company> <book> </books> I need to check who the owner is of the book and then get the details for each owner as firstname last name: john green, mary jones in the first example above or big company 3 in the 2nd example. I can't seem to find a way to get this to work in LINQ without looping through an initial query to get the id's and figuring out which type I'm dealing with (if author comes back as empty then must be company) and then looping through the document again to build up the string. Is there a neat way to do this in one query? |
|
|
|
Mar 18 2008, 11:49 AM
Post
#2
|
|
|
Active Member ![]() ![]() Group: Members Posts: 20 Joined: 16-February 08 Member No.: 90 |
Hi Bernard
I noticed you've cross-posted to Microsoft's LINQ forum. I expect you'll receive a reply from there fairly soon! Regards Joe |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 16th May 2008 - 10:48 AM |