I’m trying to write a function that will return all the available cars for rent from a single table Cars. Cars has carId(int), carManufacturer(varchar), carModel(varchar) and carTaken(bool).
But I am having problem with figuring out what datatype should the function GetAvailableCars() return.
I want to place all of the cars that are rentable(carTaken == false) into a textArea on the web-client’s simple page in a formatted way. I though string[] would be a good choice.
public string[] GetAllAvailableCars()
{
var result =
from car in carsDB.Cars
where (car.carTaken == false)
select car;
return result;
}
If you want to return a string array, something like:
Should work
EDIT: Per the request of author, to select all of the columns:
I can’t compile against your Cars class, but I think the above is right. Let me know if you get any errors.