Error 1 Cannot implicitly convert type 'System.Linq.IQueryable
I feel its just a basic error on my part but cant see it. Here is my code
cwkService
public List
{
List
select new getCarDetails
{
CarName = list.CarType.CarTypeName,
NumDoors = list.CarType.NumberOfDoors,
};
return details;
}
ICwkService
[DataContract]
public class getCarDetails
{
string carName;
int numDoors;
[DataMember]
public string CarName
{
get { return carName; }
set { carName = value; }
}
[DataMember]
public int NumDoors
{
get { return numDoors; }
set { numDoors = value; }
}
}
Any advice would be greatly appreciated, kind of hit a brick wall with it now
Thanks
Jason
Amit ChoudharyPosted Sep 27, 2010, 1:04 AM
Below statement is the source of error:
List
The linq query returns an type of IQueryable you cannot directly conver it into the List
Try this IEnumerable
or another solution is to get the returned result in
var Details= from list in .....
and then run a forloop add result into List
List
foreach(getCarDetails item in Details)
{
ls.add(item);
}
return ls;
Please mark "Do you like this post" if it helps you