LINQ to XML : A query body must end with a select clause or a group clause

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2012-12-04T16:29:08Z Indexed on 2012/12/04 17:04 UTC
Read the original article Hit count: 583

Filed under:
|

Can someone guide me on to repairing the error on this query :

       var objApps = from item in xDoc.Descendants("VHost") 
                          where(from x in item.Descendants("Application"))
                          select new clsApplication
                       {
                           ConnectionsTotal = item.Element("ConnectionsTotal").Value
                       };

It displays a compiler error "A query body must end with a select clause or a group clause". Where am I going wrong?

Would appreciate any help..

Thanks.

Edit : Here is my XML(haven't closed the tags here)...I need the connectioncount values inside the Application..

    - <Server>
  <ConnectionsCurrent>67</ConnectionsCurrent> 
  <ConnectionsTotal>1424182</ConnectionsTotal> 
  <ConnectionsTotalAccepted>1385091</ConnectionsTotalAccepted> 
  <ConnectionsTotalRejected>39091</ConnectionsTotalRejected> 
  <MessagesInBytesRate>410455.0</MessagesInBytesRate> 
  <MessagesOutBytesRate>540146.0</MessagesOutBytesRate> 
- <VHost>
  <Name>_defaultVHost_</Name> 
  <TimeRunning>5129615.178</TimeRunning> 
  <ConnectionsLimit>0</ConnectionsLimit> 
  <ConnectionsCurrent>67</ConnectionsCurrent> 
  <ConnectionsTotal>1424182</ConnectionsTotal> 
  <ConnectionsTotalAccepted>1385091</ConnectionsTotalAccepted> 
  <ConnectionsTotalRejected>39091</ConnectionsTotalRejected> 
  <MessagesInBytesRate>410455.0</MessagesInBytesRate> 
  <MessagesOutBytesRate>540146.0</MessagesOutBytesRate> 
- <Application>
  <Name>TestApp</Name> 
  <Status>loaded</Status> 
  <TimeRunning>411642.953</TimeRunning> 
  <ConnectionsCurrent>11</ConnectionsCurrent> 
  <ConnectionsTotal>43777</ConnectionsTotal> 
  <ConnectionsTotalAccepted>43135</ConnectionsTotalAccepted> 
  <ConnectionsTotalRejected>642</ConnectionsTotalRejected> 
  <MessagesInBytesRate>27876.0</MessagesInBytesRate> 
  <MessagesOutBytesRate>175053.0</MessagesOutBytesRate>

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ