WCF dataContracts and LINQ to SQL
Iam trying to create a basic WCF service library web service which connects to a database via LINQ to SQL and returns list of DataContract marked objects but I keep recieving this error:
Error 1 Cannot implicitly convert type 'System.Linq.IQueryable<CwkServer.getCarDetails>' to 'System.Collections.Generic.List<CwkServer.getCarDetails>'. An explicit conversion exists (are you missing a cast?) C:\Users\Cameron\Documents\Visual Studio 2008\Projects\CwkServer\CwkServer\CwkService.cs 34 22 CwkServer
I feel its just a basic error on my part but cant see it. Here is my code
cwkService
public List<getCarDetails> getDetails()
{
List<getCarDetails> details = from list in db.Listings
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