ASP.NET - ANONYMOUSTYPE

 
Vista:

ANONYMOUSTYPE

Publicado por Li (18 intervenciones) el 04/06/2008 13:33:56
Hola de nuevo.... no he visto nada sobre este tema por aquí así que dejo este post a ver si me arrojais algo de luz al asunto, muchas gracias.

estyo haciendo esta consulta en Linq to Entities, pero me da un fallo de que no puedo convetir el tipo anonimo a string, concretamente me dice:

"Cannot implicitly convert type System.Linq.IQueryable<AnonymousType#1> to string"

public ArrayList getInformes(string idClave)
{
ArrayList array;

var resul = from c in dataContext.Actividades
where c.Clave== idClave
select c;

array = new ArrayList((ICollection)resul.ToList());

ArrayList salida = new ArrayList();
var resultado = "";
if (array.Count > 0)
{
foreach (string actividad in array)
{
resultado = from f in dataContext.Informes
where f.IdActividad.Equals(actividad)
select new
{
f.IdInforme,
f.Descripcion,
};

salida.AddRange(resultado.ToList());
}
}
return salida;
}

alguien sabe de qué puede ser???? como puedo hacer para que los tipos coincidan??? con cast no me funciona. Bueno muchas gracias pot todo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:ANONYMOUSTYPE

Publicado por Javier Santamaria (59 intervenciones) el 05/06/2008 11:22:33
Hola,

En que linea te da el fallo exactamente?

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ANONYMOUSTYPE

Publicado por li (18 intervenciones) el 05/06/2008 14:24:59
Ok el fallo me daba en la línea del FOREACH.... los tipos no acababa de cuadrarlos. Al final lo he hecho así.

public ArrayList getInformes(string clave)
{
var result = from c in dataContext.Actividades
where c.idClave == clave
select c.actividad;
ArrayList prueba = new ArrayList();

for (int i = 0; i < result.Count(); i++)
{
prueba.AddRange(getReports(result.ToList().ElementAt(i).IdClave.ToString()));
}
return prueba;
}

public ArrayList getReports(string idclave)
{
var res = from p in dataContext.Informes
where p.IdClave == idclave
select p;
ArrayList salida = new ArrayList((ICollection)res.ToList());
return salida;
}

espero que sea útil para alguien. Un saludo y gracias por la ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar