.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

C# OOP Help

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
 
Hi, 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>(); try { DataTable data = DataManager.ExecuteQuery("sp_GetCars"); foreach (DataRow row in data.Rows) { cars.Add(new Car(Convert.ToInt32(row["Id"]), row["CarType"].ToString(), etc  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


More Related Resource Links

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend