How do I correctly return a list of "CarTypes" objects (from the second method), where the TyreID that is passed in, is not the primary key of the CarType class - so for example, I want to return a list of all CarTypes, where the TyreID is 5:
// GET api/CarTypes
public IEnumerable<CarTypes> GetCarTypes()
{
return db.CarTypes.AsEnumerable(); //This works fineCar
}
// GET api/CarTypes/5
public IEnumerable<CarTypes> GetCarTypes(long id)
{
CarTypes cartypes = db.CarTypes.Select(t => t.TyreID == id).AsEnumerable();
if (roomtypes == null)
{
throw new HttpResponseException(Request
.CreateResponse(HttpStatusCode.NotFound));
}
return cartypes;
}
It currently shows the error:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'MvcApplication4.Models.CarTypes'. An explicit conversion exists (are you missing a cast?)
And does it matter if I use Select/SelectMany/Where in the query?