You're not returning the type you said you would. You're returning an anonymous type. Fix this by projecting into the known type:
public IEnumerable<Pedidos> Pedidos_Listar()
{
using (var context = new OhmioEntities())
{
var _ped =
from Pedidos in context.Pedidos
where Pedidos.ID_Cliente == 1
select new Pedidos {Id = Pedidos.ID_Pedido, Fecha = Pedidos.Fecha, Clientes = Pedidos.Clientes};
return _ped.ToList();
}
}
Or if you don't need the projection and are returning the EF model directly:
public IEnumerable<Pedidos> Pedidos_Listar()
{
using (var context = new OhmioEntities())
{
var _ped =
from Pedidos in context.Pedidos
where Pedidos.ID_Cliente == 1
select Pedidos;
return _ped.ToList();
}
}
Or simply:
public IEnumerable<Pedidos> Pedidos_Listar()
{
using (var context = new OhmioEntities())
{
return context.Pedidos.Where(p => p.ID_Cliente == 1);
}
}