score:3

Accepted answer

You can use the let clause to declare intermediate variables:

XDocument reportDoc = XDocument.Load(@"Report.xml");
var query = from item in reportDoc.Element("Root").Descendants()
let x = Convert.ToInt32(ticket.Element("X").Value)
let y = Convert.ToInt32(ticket.Element("Y").Value)
select new Item()
{
   X = x,
   Y = y
   Z = x * y
};

Related Query

More Query from same tag