que tienen un método:No se puede convertir implícitamente el tipo 'System.Linq.IQueryable' a 'System.Collections.Generic.IList'
public DzieckoAndOpiekunCollection GetChildAndOpiekunByFirstnameLastname(string firstname, string lastname)
{
DataTransfer.ChargeInSchoolEntities db = new DataTransfer.ChargeInSchoolEntities();
DzieckoAndOpiekunCollection result = new DzieckoAndOpiekunCollection();
if (firstname == null && lastname != null)
{
IList<DzieckoAndOpiekun> resultV = from p in db.Dziecko
where lastname == p.Nazwisko
**select** new DzieckoAndOpiekun(
p.Imie,
p.Nazwisko,
p.Opiekun.Imie,
p.Opiekun.Nazwisko)
;
result.AddRange(resultV);
}
return result;
}
y error en su lugar seleccionado:
de error 1 No se puede convertir implícitamente el tipo 'System.Linq.IQueryable <WcfService1.DzieckoAndOpiekun>' en 'System.Collections.Generic.IList <WcfService1.DzieckoAndOpiekun>'. Existe una conversión explícita (¿falta un molde?)
¿Alguna idea de cómo resolver mi problema?
Solución ideal, Tnx !! :) – netmajor
Por supuesto, la extensión '.ToArray()' Linq también podría usarse en este caso (porque un 'T []' es un 'IList' también). Pero, ¿qué requiere el método 'AddRange'? Tal vez podría simplemente usar 'var' (lo que significaría' IQueryable 'aquí), y' AddRange' estaría contento con eso? Nota: 'IQueryable <>' hereda 'IEnumerable <>'. –