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>
The compiler is complaining about this part
inside your
Whereclause. You should change it so thatselectclause at the end, andtrueforitemobjects that you would like to keep.Here is my best guess at what you are trying to do (EDIT : attempt number two)