I have a C# web app written in .Net3.5. It consists of some webpages, a data layer and a business layer project.
To simplify my question I have a class "Car", this Car object has a corresponding Car SQL table and a related CarType table .
I have a view in the database which joins Car and CarType. In my Car class I have a method "GetCars" which calls the above view so that I can read the car type value rather than returning the Id - the problem is that I want to return a list of Car objects but am struggling to understand how to do it as my Car constructor doesn't cater for the join that I return in my stored proc.
E.G.public List<Car> GetCars()
List<Car> cars= new List<Car>();
DataTable data = DataManager.ExecuteQuery("sp_GetCars");
foreach (DataRow row in data.Rows)
cars.Add(new Car(Convert.ToInt32(row["Id"]), row["CarType"].ToString(),
So the problem is that my constructor doesn't cater for "CarType", it has CarTypeId but that's not what I need.
Secondly I guess I could just return a DataTable and bypass the need to create an object but I would prefer to create the objects as above.
Does this make any sense? Can anyone help me which this co
View Complete Post