Monday, 19 August 2013

cannot passing anonymous variable c# by a parameter on the method LINQ

cannot passing anonymous variable c# by a parameter on the method LINQ

I need do something like this
public class carros {
public int id { get; set; }
public string nome { get; set; }
public carros(int _id, string _nome)
{
id = _id;
nome = _nome;
}
}
public void listar_carros()
{
List<carros> Lcars = new List<carros>();
Lcars.Add(new carros(1, "Fusca"));
Lcars.Add(new carros(2, "Gol"));
Lcars.Add(new carros(3, "Fiesta"));
var qry = from q in Lcars where q.nome.ToLower().Contains("eco")
orderby q.nome select new {q.nome, q.id};
doSomething(qry)
}
public void
{
foreach (carros ca in qry)
{
Response.Write(ca.nome);
Response.Write(" - ");
Response.Write(ca.id);
//Response.Write(ca);
Response.Write("<br />");
}
}
I need pass this variable "qry" for function doSomething. i try do a
dynamic type, List, object nothing works

No comments:

Post a Comment