Với IQueryable tuy nhiên, bạn có tính linh hoạt nhiều hơn nữa với các hoạt động truy vấn của bạn. Hãy nhớ rằng, mặc dù giao diện IQueryable thực hiện IEnumerable, mà cung cấp IQueryable với khả năng lặp đi lặp lại. Có hai loại của các nhà khai thác truy vấn. Loại đầu tiên hoạt động trên các đối tượng IEnumerable, trong khi các hoạt động trên IQueryable | Part II LINQtoXML Employee id 3 Dept 0004 Geek True Name Joe Name Address Street 222 Main St. Street City Easley City State SC State Address Title All Things Bleeding Edge Title HireDate 07 22 2004 HireDate Gender M Gender Employee Employees The following example queries the XML document looking at the Geek attribute of the Employee node and returning only those with a value of True IEnumerable XElement empNames from emp in Employee where string Geek True select emp foreach XElement name in empNames The query expression returns the following values Scott Joe This last example demonstrates how to walk an XML tree looking for an element value several layers deep. First modify the XML and add a Zip element to the employee with an id of 2 Employee id 2 Dept 0005 Geek False Name Steve Name Address Street 444 Main St. Street City Snohomish City State WA state Zip 99999 Zip Address Title Mr. SciFi Title HireDate 05 14 2002 HireDate Gender M Gender Employee In the following example the query expression walks down to the Address element and looks for an employee with a Zip value of 99999 IEnumerable XElement empAddr from emp in Employee .Elements Address where string zip 99999 136 Chapter 6 Programming with LINQ to XML select emp foreach XElement address in empAddr There was only a single employee that matched the query expression filter in this example but nonetheless the results were looped through and the following XML was returned Address Street 444 Main St. Street City Snohomish City State WA State Zip 99999 Zip Address This example returned the address information for the selected ZIP code. Modify the query as highlighted here and it will return the entire employee node for the selected ZIP code IEnumerable XElement empAddr from emp in Employee where string Address .Element zip 99999 select emp Now when you run this