EDN Admin
Well-known member
I have a query
<div style="color:Black;background-color:White; <pre>
XDocument custDoc = XDocument.Load(<span style="color:#A31515; @"C:Usersgabrielle.stantonDocumentsVisual Studio 2010ProjectsKioskApplicationKioskApplicationCustomerData.xml");
IEnumerable<XElement> customers = <span style="color:Blue; from c <span style="color:Blue; in custDoc.Elements(<span style="color:#A31515; "customer")
<span style="color:Blue; where c.Element(<span style="color:#A31515; "fullName").Value.ToLower().Contains(custNameLower) && c.Element(<span style="color:#A31515; "address").Element(<span style="color:#A31515; "line1").Value.ToLower().Contains(addressLine1)
<span style="color:Blue; select c;
[/code]
(my customerNameLower is andy anderson and my addressLine1 is 344 washington ave)
and a xml source:
<div style="color:Black;background-color:White; <pre>
<customers>
<customer>
<id>500734</id>
<fullName>Andy Anderson</fullName>
<address>
<line1>344 Washington Avenue</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>871640</number>
<bills>
<bill>
<number>11254</number>
<type>Utility</type>
<amountDue>284.50</amountDue>
<dueDate>2011-07-31</dueDate>
</bill>
<bill>
<number>26488</number>
<type>General</type>
<amountDue>126.68</amountDue>
<dueDate>2011-08-01</dueDate>
</bill>
</bills>
</account>
</accounts>
</customer>
<customer>
<id>863532</id>
<fullName>Rick Taylor</fullName>
<address>
<line1>343 Forest Avenue</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>665422</number>
<bills>
<bill>
<number>65384</number>
<type>Utility</type>
<amountDue>123.75</amountDue>
<dueDate>2011-08-31</dueDate>
</bill>
<bill>
<number>34256</number>
<type>General</type>
<amountDue>362.45</amountDue>
<dueDate>2011-07-31</dueDate>
</bill>
</bills>
</account>
</accounts>
</customer>
<customer>
<id>824136</id>
<fullName>Jared Jackson</fullName>
<address>
<line1>72 High Street</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>562310</number>
<licenses>
<licence>
<tagNumber>4379</tagNumber>
<type>Animal License</type>
<animalType>Dog</animalType>
<name>Arnold</name>
<rabiesDate></rabiesDate>
<year>2011</year>
<fee>15.16</fee>
</licence>
</licenses>
</account>
</accounts>
</customer>
</customers>
[/code]
<br/>
and when i step through the query it says the enumeration comes back empty...
I cant figure out why!
Any suggestions??
Thanks!
<br/>
<br/>
View the full article
<div style="color:Black;background-color:White; <pre>
XDocument custDoc = XDocument.Load(<span style="color:#A31515; @"C:Usersgabrielle.stantonDocumentsVisual Studio 2010ProjectsKioskApplicationKioskApplicationCustomerData.xml");
IEnumerable<XElement> customers = <span style="color:Blue; from c <span style="color:Blue; in custDoc.Elements(<span style="color:#A31515; "customer")
<span style="color:Blue; where c.Element(<span style="color:#A31515; "fullName").Value.ToLower().Contains(custNameLower) && c.Element(<span style="color:#A31515; "address").Element(<span style="color:#A31515; "line1").Value.ToLower().Contains(addressLine1)
<span style="color:Blue; select c;
[/code]
(my customerNameLower is andy anderson and my addressLine1 is 344 washington ave)
and a xml source:
<div style="color:Black;background-color:White; <pre>
<customers>
<customer>
<id>500734</id>
<fullName>Andy Anderson</fullName>
<address>
<line1>344 Washington Avenue</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>871640</number>
<bills>
<bill>
<number>11254</number>
<type>Utility</type>
<amountDue>284.50</amountDue>
<dueDate>2011-07-31</dueDate>
</bill>
<bill>
<number>26488</number>
<type>General</type>
<amountDue>126.68</amountDue>
<dueDate>2011-08-01</dueDate>
</bill>
</bills>
</account>
</accounts>
</customer>
<customer>
<id>863532</id>
<fullName>Rick Taylor</fullName>
<address>
<line1>343 Forest Avenue</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>665422</number>
<bills>
<bill>
<number>65384</number>
<type>Utility</type>
<amountDue>123.75</amountDue>
<dueDate>2011-08-31</dueDate>
</bill>
<bill>
<number>34256</number>
<type>General</type>
<amountDue>362.45</amountDue>
<dueDate>2011-07-31</dueDate>
</bill>
</bills>
</account>
</accounts>
</customer>
<customer>
<id>824136</id>
<fullName>Jared Jackson</fullName>
<address>
<line1>72 High Street</line1>
<line2></line2>
<zip>04102</zip>
<city>Portland</city>
<state>ME</state>
</address>
<accounts>
<account>
<number>562310</number>
<licenses>
<licence>
<tagNumber>4379</tagNumber>
<type>Animal License</type>
<animalType>Dog</animalType>
<name>Arnold</name>
<rabiesDate></rabiesDate>
<year>2011</year>
<fee>15.16</fee>
</licence>
</licenses>
</account>
</accounts>
</customer>
</customers>
[/code]
<br/>
and when i step through the query it says the enumeration comes back empty...
I cant figure out why!
Any suggestions??
Thanks!
<br/>
<br/>
View the full article