LINQ to XML where clause

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi All,
I am writing the following code

<pre> XDocument replies = XDocument.Load("reply.xml");

var answers = from reply in replies.Descendants("Reply")
where reply.Element("QID").Value == QuestionID
select new Reply
{
QID = (string)reply.Element("QID"),
Answer = (string)reply.Element("Answer")
};[/code]

The QuestionID is a property here. Now if I assign value to this property and use in the above code, it does not work.
However if I use hardcoded string for example "1", it works. Can someone help me what could be an issue??
Thanks <hr class="sig Student

View the full article
 
Back
Top