The code snippet:
Code:
XDocument xdoc = XDocument.Load(@"C:\hamlet.xml");
var query = from people in xdoc.Descendants("PERSONA") select people.Value;
Console.WriteLine("{0} Players Found", query.Count());
Console.WriteLine();
foreach (var item in query)
{
Console.WriteLine(item);
}
Console.ReadLine();
fails to compile in Visual C# 2008 Express. The error:
Error 1 Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable<System.Xml .Linq.XElement>'. 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'? C:\Users\DaveTheCaver\Desktop\ProC#Book\ch29 CodeSample\Chapter 29\ConsoleApplication1\ConsoleApplication1\Program .cs 15 40 ConsoleApplication1
appears to be complaining about xdoc.Descendants("PERSONA"). The project has a reference to the System.Core.DLL and a using System.Linq directive.
Is there another reason for this error?