I’m working on a project where I’m trying to use entity framework to provide data to a WCF service. The code follows:
public IQueryable<vwTP90Web> GetTP90()
{
TP90Entities context = new TP90Entities();
var tp90web = (from p
in context.vw_TP90Web
select p).Cast<IQueryable<vwTP90Web>>();
return tp90web;
}
it works fine until I try to return the data and then I get the message:
Cannot implicitly convert type
'System.Linq.IQueryable<System.Linq.IQueryable<TP90Service.vwTP90Web>>' to
'System.Linq.IQueryable<TP90Service.vwTP90Web>'. An explicit conversion exists (are
you missing a cast?)
I’ve been chasing this for days and I just can’t wrap my head around what it’s looking for. I had the service running when I returned one item,but for the project I need to return a list. Can someone explain to me what I’m doing wrong?
You don’t need to include the
IQueryable<T>in your cast:Note that this will still fail at runtime if the query is not returning
vwTP90Webinstances.