Tengo una consulta que devuelve un tipo anónimo y la consulta está en un método. Cómo se escribe esto:Devolviendo el tipo anónimo en C#
public "TheAnonymousType" TheMethod(SomeParameter)
{
using (MyDC TheDC = new MyDC())
{
var TheQueryFromDB = (....
select new { SomeVariable = ....,
AnotherVariable = ....}
).ToList();
return "TheAnonymousType";
}
}
¿Por qué le gustaría devolver un tipo anónimo? ¿Cómo podría usar ese resultado en otro lugar? – Yuck
posible duplicado de [¿Cómo puedo devolver un tipo anónimo desde un método?] (Http://stackoverflow.com/questions/55101/how-can-i-return-an-anonymous-type-from-a-method) – nawfal
@Yuck, ¿qué pasa si estás devolviendo json o algo donde el tipo de C# no importa? – aw04