por Cesar Cassiano Schimanco

Resolver - "Select", "Where" not found - LINQ

Os erros 'Where' not found e 'Select' not found ocorrem por estar faltando a linha abaixo no .cs da página.

using System.Linq;

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1935: Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>'. 'Where' not found. Are you missing a reference or a using directive for 'System.Linq'?

Source Error:

 
Line 45:         XElement xml = XElement.Load(MapPath("~/exemplo.xml"));
Line 46:         IEnumerable<XElement> contatos =
Line 47:             from el in xml.Elements("contato").Elements("nome") Line 48:             //Verificar se não é null e se o atributo é = valor2
Line 49:             where el.Attribute("atributo") != null && el.Attribute("atributo").Value == "valor2"

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1935: 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 or a using directive for 'System.Linq'?

Source Error:

 
Line 45:         XElement xml = XElement.Load(MapPath("~/exemplo.xml"));
Line 46:         IEnumerable<XElement> contatos =
Line 47:             from el in xml.Elements("contato").Elements("nome") Line 48:             select el;
Line 49:         //foreach (XElement el in contatos)

Comentários

Carregando comentários

Postar um novo comentário



Processando...